* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  background: #0a0a1a;
  min-height: 100vh;
  overflow-x: hidden;
  font-family: system-ui, sans-serif;
  color: #e0e0e0;
}

/* Scanline overlay */
.scanlines {
  pointer-events: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  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
  );
}

.scanlines-off {
  display: none;
}

/* CRT bezel */
.crt-bezel {
  background: linear-gradient(145deg, #3a3a4a 0%, #1a1a2a 50%, #2a2a3a 100%);
  border-radius: 20px;
  padding: 16px;
  box-shadow:
    0 0 0 2px #555,
    0 0 0 4px #222,
    inset 0 2px 8px rgba(255,255,255,0.05),
    0 8px 32px rgba(0,0,0,0.6);
  position: relative;
}

.crt-bezel::before {
  content: '';
  position: absolute;
  top: 4px;
  left: 20%;
  right: 20%;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
  border-radius: 50%;
}

.crt-screen {
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  aspect-ratio: 4/3;
  box-shadow: inset 0 0 30px rgba(0,0,0,0.5);
}

.crt-curvature {
  border-radius: 16px;
}

.crt-curvature::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 16px;
  background: radial-gradient(ellipse at 30% 20%, rgba(255,255,255,0.03) 0%, transparent 60%);
  pointer-events: none;
}

/* Cartridge slot */
.cartridge-slot {
  background: linear-gradient(180deg, #1a1a2a 0%, #0d0d1a 100%);
  border: 3px solid #2a2a3a;
  border-top: 4px solid #3a3a4a;
  border-bottom: 4px solid #111;
  border-radius: 4px;
  position: relative;
  transition: all 0.3s ease;
}

.cartridge-slot:hover,
.cartridge-slot.drag-over {
  border-color: #ce93d8;
  box-shadow: 0 0 20px rgba(206, 147, 216, 0.2);
}

.cartridge-slot.drag-over {
  background: linear-gradient(180deg, #1a1030 0%, #0d0820 100%);
}

/* SNES-style button */
.snes-btn {
  font-family: 'Press Start 2P', monospace;
  border: none;
  cursor: pointer;
  transition: all 0.1s ease;
  position: relative;
}

.snes-btn:active {
  transform: scale(0.95) translateY(2px);
}

.snes-btn-purple {
  background: linear-gradient(180deg, #7b1fa2 0%, #4a148c 100%);
  color: #fff;
  border-radius: 24px;
  padding: 12px 24px;
  box-shadow: 0 4px 0 #311b6b, 0 6px 12px rgba(0,0,0,0.3);
}

.snes-btn-purple:active {
  box-shadow: 0 1px 0 #311b6b, 0 2px 4px rgba(0,0,0,0.3);
}

/* Virtual gamepad */
.dpad {
  position: relative;
  width: 120px;
  height: 120px;
}

.dpad-btn {
  position: absolute;
  background: linear-gradient(145deg, #3a3a4a, #2a2a3a);
  border: 1px solid #444;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #888;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: background 0.1s;
}

.dpad-btn:active, .dpad-btn.pressed {
  background: linear-gradient(145deg, #5a5a6a, #4a4a5a);
  color: #ccc;
}

.dpad-up { top: 0; left: 36px; width: 48px; height: 44px; border-radius: 6px 6px 0 0; }
.dpad-down { bottom: 0; left: 36px; width: 48px; height: 44px; border-radius: 0 0 6px 6px; }
.dpad-left { top: 36px; left: 0; width: 44px; height: 48px; border-radius: 6px 0 0 6px; }
.dpad-right { top: 36px; right: 0; width: 44px; height: 48px; border-radius: 0 6px 6px 0; }
.dpad-center { top: 36px; left: 36px; width: 48px; height: 48px; background: #2a2a3a; border: 1px solid #333; }

.face-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  color: #fff;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: all 0.1s;
  box-shadow: 0 3px 0 rgba(0,0,0,0.3);
}

.face-btn:active, .face-btn.pressed {
  transform: scale(0.92);
  box-shadow: 0 1px 0 rgba(0,0,0,0.3);
}

.shoulder-btn {
  background: linear-gradient(180deg, #4a4a5a, #3a3a4a);
  border: 1px solid #555;
  border-radius: 8px 8px 4px 4px;
  padding: 8px 28px;
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  color: #aaa;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: all 0.1s;
}

.shoulder-btn:active, .shoulder-btn.pressed {
  background: linear-gradient(180deg, #5a5a6a, #4a4a5a);
  transform: translateY(2px);
}

.center-btn {
  background: linear-gradient(180deg, #3a3a4a, #2a2a3a);
  border: 1px solid #444;
  border-radius: 12px;
  padding: 6px 16px;
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  color: #888;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: all 0.1s;
}

.center-btn:active, .center-btn.pressed {
  background: linear-gradient(180deg, #4a4a5a, #3a3a4a);
  transform: scale(0.95);
}

/* Cartridge animation */
@keyframes cartridgeInsert {
  0% { transform: translateY(-60px); opacity: 0.5; }
  60% { transform: translateY(4px); }
  80% { transform: translateY(-2px); }
  100% { transform: translateY(0); opacity: 1; }
}

.cartridge-inserting {
  animation: cartridgeInsert 0.6s ease-out;
}

/* Konami confetti */
@keyframes confettiFall {
  0% { transform: translateY(-10vh) rotate(0deg); opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}

.confetti-piece {
  position: fixed;
  width: 10px;
  height: 10px;
  z-index: 10000;
  animation: confettiFall 3s ease-in forwards;
}

/* Glow effect */
.glow-purple {
  box-shadow: 0 0 12px rgba(206, 147, 216, 0.3);
}

/* Emulator iframe */
.emulator-frame {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* Settings modal overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.modal-content {
  background: linear-gradient(180deg, #1e1e30 0%, #14142a 100%);
  border: 1px solid #3a3a5a;
  border-radius: 12px;
  max-width: 500px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px;
}

/* Sidebar */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 300px;
  background: linear-gradient(180deg, #14142a 0%, #0a0a1a 100%);
  border-right: 1px solid #2a2a3a;
  z-index: 500;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  overflow-y: auto;
}

.sidebar.open {
  transform: translateX(0);
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 499;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #0a0a1a; }
::-webkit-scrollbar-thumb { background: #3a3a5a; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #4a4a6a; }

/* First visit tutorial */
@keyframes tutorialPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.tutorial-pulse {
  animation: tutorialPulse 2s ease-in-out infinite;
}

/* Keyboard overlay */
.kbd {
  display: inline-block;
  padding: 2px 6px;
  background: #2a2a3a;
  border: 1px solid #4a4a5a;
  border-radius: 4px;
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: #ccc;
}