@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

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

body {
  background: #1a1a2e;
  background-image: 
    radial-gradient(ellipse at 50% 0%, #2a2a4e 0%, transparent 70%),
    repeating-linear-gradient(0deg, transparent, transparent 3px, rgba(255,255,255,0.01) 3px, rgba(255,255,255,0.01) 4px);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: 'Press Start 2P', monospace;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

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

.gameboy-shell {
  position: relative;
  width: 340px;
  background: linear-gradient(145deg, #c8c8c8 0%, #b8b8b8 30%, #a8a8a8 100%);
  border-radius: 12px 12px 60px 12px;
  padding: 20px 18px 30px;
  box-shadow: 
    0 8px 30px rgba(0,0,0,0.5),
    inset 0 1px 0 rgba(255,255,255,0.4),
    inset 0 -2px 0 rgba(0,0,0,0.15),
    4px 4px 0 rgba(0,0,0,0.2);
  user-select: none;
}

.gameboy-shell.dark-mode {
  background: linear-gradient(145deg, #7a7a8a 0%, #606070 30%, #505060 100%);
}

.screen-bezel {
  background: linear-gradient(180deg, #40405a 0%, #303048 100%);
  border-radius: 10px;
  padding: 20px 14px 10px;
  margin-bottom: 12px;
  box-shadow: 
    inset 0 4px 12px rgba(0,0,0,0.6),
    inset 0 1px 0 rgba(0,0,0,0.3);
  position: relative;
}

.power-led {
  position: absolute;
  top: 8px;
  left: 14px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #3a1010;
  box-shadow: none;
  transition: all 0.3s;
}

.power-led.on {
  background: #ff2020;
  box-shadow: 0 0 8px #ff2020, 0 0 16px rgba(255,32,32,0.4);
  animation: led-pulse 2s ease-in-out infinite;
}

@keyframes led-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.battery-text {
  position: absolute;
  top: 6px;
  left: 26px;
  font-size: 5px;
  color: #606080;
  letter-spacing: 1px;
}

.lcd-screen {
  background: #9bbc0f;
  border-radius: 4px;
  position: relative;
  overflow: hidden;
  aspect-ratio: 160/144;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.3);
}

.lcd-screen::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 1px,
    rgba(0,0,0,0.04) 1px,
    rgba(0,0,0,0.04) 2px
  );
  pointer-events: none;
  z-index: 5;
}

.lcd-screen canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100% !important;
  height: 100% !important;
  image-rendering: pixelated;
  z-index: 1;
}

.brand-area {
  text-align: center;
  padding: 6px 0 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.brand-line {
  height: 2px;
  flex: 1;
  background: linear-gradient(90deg, transparent, #6060a0, transparent);
}

.brand-text {
  font-size: 7px;
  color: #3030a0;
  letter-spacing: 2px;
  white-space: nowrap;
}

.dark-mode .brand-text { color: #9090c0; }

.dpad-container {
  position: relative;
  width: 90px;
  height: 90px;
}

.dpad-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 30px;
  height: 30px;
  background: #303030;
  border-radius: 50%;
  z-index: 3;
}

.dpad-arm {
  position: absolute;
  background: #2a2a2a;
  cursor: pointer;
  transition: background 0.05s;
  z-index: 2;
}

.dpad-arm:active, .dpad-arm.pressed {
  background: #1a1a1a;
}

.dpad-arm.up {
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 30px; height: 36px;
  border-radius: 4px 4px 0 0;
}
.dpad-arm.down {
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 30px; height: 36px;
  border-radius: 0 0 4px 4px;
}
.dpad-arm.left {
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 36px; height: 30px;
  border-radius: 4px 0 0 4px;
}
.dpad-arm.right {
  right: 0; top: 50%;
  transform: translateY(-50%);
  width: 36px; height: 30px;
  border-radius: 0 4px 4px 0;
}

.dpad-arm .arrow {
  position: absolute;
  font-size: 10px;
  color: #505050;
  pointer-events: none;
}

.dpad-arm.up .arrow { top: 4px; left: 50%; transform: translateX(-50%); }
.dpad-arm.down .arrow { bottom: 4px; left: 50%; transform: translateX(-50%); }
.dpad-arm.left .arrow { left: 6px; top: 50%; transform: translateY(-50%); }
.dpad-arm.right .arrow { right: 6px; top: 50%; transform: translateY(-50%); }

.ab-button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(145deg, #a01040, #801030);
  border: none;
  cursor: pointer;
  box-shadow: 
    0 3px 0 #600820,
    0 4px 6px rgba(0,0,0,0.3),
    inset 0 1px 0 rgba(255,255,255,0.15);
  color: #d06080;
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.05s;
  -webkit-tap-highlight-color: transparent;
}

.ab-button:active, .ab-button.pressed {
  transform: translateY(2px);
  box-shadow: 
    0 1px 0 #600820,
    0 1px 3px rgba(0,0,0,0.3),
    inset 0 1px 0 rgba(255,255,255,0.15);
}

.ss-button {
  width: 44px;
  height: 14px;
  border-radius: 7px;
  background: linear-gradient(180deg, #505050, #404040);
  border: none;
  cursor: pointer;
  box-shadow: 
    0 2px 0 #2a2a2a,
    inset 0 1px 0 rgba(255,255,255,0.1);
  color: #808080;
  font-family: 'Press Start 2P', monospace;
  font-size: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.05s;
  -webkit-tap-highlight-color: transparent;
}

.ss-button:active, .ss-button.pressed {
  transform: translateY(1px);
  box-shadow: 0 1px 0 #2a2a2a;
}

.speaker-grille {
  position: absolute;
  bottom: 30px;
  right: 18px;
  width: 50px;
  height: 50px;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(6, 1fr);
  gap: 2px;
  transform: rotate(-25deg);
}

.speaker-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #909090;
  transition: background 0.1s;
}

.dark-mode .speaker-dot { background: #404050; }

.speaker-dot.active {
  background: #606060;
}

.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.2s;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background: #2a2a3e;
  border: 3px solid #9bbc0f;
  border-radius: 8px;
  padding: 16px;
  max-width: 380px;
  width: 92%;
  max-height: 80vh;
  overflow-y: auto;
  animation: slideUp 0.3s;
}

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

.modal-content::-webkit-scrollbar { width: 6px; }
.modal-content::-webkit-scrollbar-track { background: #1a1a2e; }
.modal-content::-webkit-scrollbar-thumb { background: #9bbc0f; border-radius: 3px; }

.track-item {
  padding: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: 4px;
  transition: all 0.1s;
  margin-bottom: 4px;
}

.track-item:hover, .track-item.selected {
  background: rgba(155, 188, 15, 0.1);
  border-color: #9bbc0f;
}

.track-item .genre-badge {
  display: inline-block;
  padding: 1px 4px;
  border: 1px solid #306230;
  border-radius: 2px;
  font-size: 4px;
  color: #8bac0f;
  margin-left: 4px;
  vertical-align: middle;
}

.track-item .featured-star {
  color: #9bbc0f;
  font-size: 6px;
}

.drop-zone {
  border: 2px dashed #9bbc0f;
  border-radius: 8px;
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 12px;
}

.drop-zone:hover, .drop-zone.dragging {
  background: rgba(155,188,15,0.1);
  border-color: #8bac0f;
}

.help-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fadeIn 0.2s;
}

.help-content {
  background: #0f380f;
  border: 3px solid #9bbc0f;
  border-radius: 8px;
  padding: 20px;
  max-width: 380px;
  width: 90%;
  color: #9bbc0f;
}

@media (max-width: 400px) {
  .gameboy-shell {
    width: 300px;
    padding: 16px 14px 26px;
  }
}

@media (max-width: 340px) {
  .gameboy-shell {
    width: 280px;
    padding: 14px 10px 22px;
  }
}