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

body {
  background: linear-gradient(135deg, #c3b1e1 0%, #e8d5f5 30%, #d4c5f0 60%, #b8a9d9 100%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: 'Press Start 2P', monospace;
  overflow: hidden;
}

#gameboy-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
}

#cartridge-label {
  background: linear-gradient(180deg, #d8c8f0 0%, #c3a8e8 100%);
  border: 2px solid #9a7bc7;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  padding: 6px 20px 4px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cart-title {
  font-size: 7px;
  color: #3a1a6a;
  letter-spacing: 1px;
}

.cart-sub {
  font-size: 10px;
}

#gameboy {
  background: linear-gradient(180deg, #c8c0b8 0%, #b0a898 50%, #a09888 100%);
  border-radius: 12px 12px 12px 60px;
  padding: 16px 20px 24px;
  box-shadow: 
    4px 4px 12px rgba(0,0,0,0.3),
    inset 0 1px 0 rgba(255,255,255,0.3),
    inset 0 -2px 4px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

#screen-bezel {
  background: linear-gradient(180deg, #454560 0%, #3a3a55 100%);
  border-radius: 8px;
  padding: 12px 16px 20px;
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.5);
  position: relative;
}

#screen-bezel::before {
  content: '● BUBBLE BOUNCERS';
  position: absolute;
  top: 3px;
  left: 16px;
  font-size: 4px;
  color: #6a6a8a;
  letter-spacing: 1px;
}

#screen-inner {
  position: relative;
  border: 2px solid #2a2a40;
  border-radius: 2px;
  overflow: hidden;
  line-height: 0;
}

#canvas {
  width: 480px;
  height: 432px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #9bbc0f;
  display: block;
}

#scanlines {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent 0px,
    transparent 2px,
    rgba(0,0,0,0.06) 2px,
    rgba(0,0,0,0.06) 3px
  );
  pointer-events: none;
}

#controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
}

#controls-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 0 8px;
}

#dpad-container {
  display: grid;
  grid-template-columns: 32px 32px 32px;
  grid-template-rows: 32px 32px 32px;
  gap: 0;
}

.dpad-btn {
  background: #2a2a30;
  border: none;
  color: #888;
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

.dpad-btn:active {
  background: #1a1a20;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.5);
}

.dpad-up { grid-column: 2; grid-row: 1; border-radius: 4px 4px 0 0; }
.dpad-down { grid-column: 2; grid-row: 3; border-radius: 0 0 4px 4px; }
.dpad-left { grid-column: 1; grid-row: 2; border-radius: 4px 0 0 4px; }
.dpad-right { grid-column: 3; grid-row: 2; border-radius: 0 4px 4px 0; }
.dpad-center { grid-column: 2; grid-row: 2; background: #2a2a30; }

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

.action-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #8a1848;
  border: 2px solid #6a1038;
  color: #ddd;
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  cursor: pointer;
  box-shadow: 0 3px 0 #5a0828, 0 4px 6px rgba(0,0,0,0.3);
  user-select: none;
}

.action-btn:active {
  box-shadow: 0 1px 0 #5a0828;
  transform: translateY(2px);
}

#controls-bottom {
  display: flex;
  gap: 20px;
  transform: rotate(-25deg);
}

.sys-btn {
  background: #7a7888;
  border: none;
  border-radius: 12px;
  padding: 4px 12px;
  font-family: 'Press Start 2P', monospace;
  font-size: 5px;
  color: #444;
  cursor: pointer;
  box-shadow: 0 2px 0 #5a5868;
  user-select: none;
}

.sys-btn:active {
  box-shadow: 0 0 0 #5a5868;
  transform: translateY(2px);
}

#mute-toggle {
  margin-top: 8px;
}

#mute-btn {
  background: rgba(255,255,255,0.3);
  border: 1px solid rgba(255,255,255,0.5);
  border-radius: 12px;
  padding: 4px 12px;
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  color: #555;
  cursor: pointer;
}

footer {
  margin-top: 12px;
  text-align: center;
  font-size: 7px;
  color: #6a5a8a;
}

footer a {
  color: #4a3a7a;
  text-decoration: none;
  margin-top: 4px;
  display: inline-block;
}

footer a:hover {
  text-decoration: underline;
}

@media (max-width: 600px) {
  #canvas {
    width: 320px;
    height: 288px;
  }

  #gameboy {
    padding: 10px 12px 18px;
    border-radius: 8px 8px 8px 40px;
  }

  #screen-bezel {
    padding: 8px 10px 14px;
  }

  .action-btn {
    width: 36px;
    height: 36px;
  }

  .dpad-btn {
    width: 28px;
    height: 28px;
  }

  #dpad-container {
    grid-template-columns: 28px 28px 28px;
    grid-template-rows: 28px 28px 28px;
  }
}

@media (max-width: 400px) {
  #canvas {
    width: 256px;
    height: 230px;
  }
}