/* ==========================================================================
   GBA Web Player - Authentic Handheld Console Chassis & Touch Controls
   Faithfully inspired by the Nintendo Game Boy Advance (AGB-001)
   ========================================================================== */

#virtual-pad-container {
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  z-index: 40;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: block;
}

#virtual-pad-container[style*="display: none"],
#virtual-pad-container.hidden,
#virtual-pad-container.vpad-hidden,
#drop-zone:not(.hidden) ~ #bezel-wrapper #virtual-pad-container {
  display: none !important;
}

/* ==========================================================================
   ON-SCREEN TRANSLUCENT OVERLAY MODE ("Na Tela, Meio Opaco")
   Floats directly over the game screen with glassmorphic transparency
   ========================================================================== */
.vpad-mode-overlay {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  margin: 0 !important;
  pointer-events: none !important;
  z-index: 50 !important;
  display: flex !important;
  flex-direction: column !important;
  justify-content: space-between !important;
}

.vpad-mode-overlay .gba-chassis-body {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 1rem 0.75rem !important;
  height: 100% !important;
  justify-content: space-between !important;
  overflow: visible !important;
}

.vpad-mode-overlay .gba-chassis-body::before,
.vpad-mode-overlay .gba-chassis-body::after {
  display: none !important;
}

/* Translucent Glass Shoulders */
.vpad-mode-overlay .gba-shoulder-btn {
  pointer-events: auto !important;
  background: rgba(255, 255, 255, 0.16) !important;
  backdrop-filter: blur(8px) !important;
  -webkit-backdrop-filter: blur(8px) !important;
  border: 1.5px solid rgba(255, 255, 255, 0.35) !important;
  color: #fff !important;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4) !important;
}

.vpad-mode-overlay .gba-pill-quick {
  pointer-events: auto !important;
  background: rgba(15, 23, 42, 0.55) !important;
  backdrop-filter: blur(8px) !important;
  -webkit-backdrop-filter: blur(8px) !important;
  border: 1px solid rgba(255, 255, 255, 0.25) !important;
}

/* Translucent Glass D-Pad */
.vpad-mode-overlay .gba-dpad-wrapper {
  pointer-events: auto !important;
}

.vpad-mode-overlay .gba-dpad-wrapper::before {
  background: radial-gradient(circle, rgba(0, 0, 0, 0.3) 60%, rgba(255, 255, 255, 0.08) 100%) !important;
  border: 1.5px solid rgba(255, 255, 255, 0.2) !important;
  backdrop-filter: blur(4px) !important;
}

.vpad-mode-overlay .gba-dpad-pivot {
  background: rgba(15, 23, 42, 0.65) !important;
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
}

.vpad-mode-overlay .gba-dpad-arm {
  background: rgba(30, 41, 59, 0.55) !important;
  backdrop-filter: blur(8px) !important;
  -webkit-backdrop-filter: blur(8px) !important;
  border: 1.5px solid rgba(255, 255, 255, 0.3) !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35) !important;
}

.vpad-mode-overlay .gba-dpad-arm .dpad-arrow {
  color: rgba(255, 255, 255, 0.9) !important;
}

.vpad-mode-overlay .gba-dpad-arm:active,
.vpad-mode-overlay .gba-dpad-arm.pressed {
  background: rgba(109, 93, 252, 0.85) !important;
  box-shadow: 0 0 16px rgba(109, 93, 252, 0.8) !important;
}

/* Translucent Action Buttons (A & B) */
.vpad-mode-overlay .gba-actions-wrapper {
  pointer-events: auto !important;
}

.vpad-mode-overlay .gba-actions-wrapper::before {
  background: radial-gradient(ellipse, rgba(0, 0, 0, 0.3) 60%, rgba(255, 255, 255, 0.08) 100%) !important;
  border: 1.5px solid rgba(255, 255, 255, 0.2) !important;
  backdrop-filter: blur(4px) !important;
}

.vpad-mode-overlay .btn-b {
  background: rgba(99, 102, 241, 0.55) !important;
  backdrop-filter: blur(8px) !important;
  -webkit-backdrop-filter: blur(8px) !important;
  border: 2px solid rgba(255, 255, 255, 0.4) !important;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35) !important;
}

.vpad-mode-overlay .btn-a {
  background: rgba(239, 68, 68, 0.55) !important;
  backdrop-filter: blur(8px) !important;
  -webkit-backdrop-filter: blur(8px) !important;
  border: 2px solid rgba(255, 255, 255, 0.45) !important;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35) !important;
}

.vpad-mode-overlay .gba-action-round:active,
.vpad-mode-overlay .gba-action-round.pressed {
  filter: brightness(1.3) !important;
  transform: translateY(2px) scale(0.95) !important;
}

/* Translucent Center Pills */
.vpad-mode-overlay .gba-center-controls {
  pointer-events: auto !important;
}

.vpad-mode-overlay .gba-pill-rubber {
  background: rgba(51, 65, 85, 0.6) !important;
  border: 1.5px solid rgba(255, 255, 255, 0.3) !important;
  backdrop-filter: blur(6px) !important;
}

.vpad-mode-overlay .gba-speaker-holes {
  display: none !important;
}

/* Opacity Preset Classes ("Meio Opaco") */
.vpad-opacity-40 {
  opacity: 0.42 !important;
}

.vpad-opacity-65 {
  opacity: 0.68 !important;
}

.vpad-opacity-90 {
  opacity: 0.92 !important;
}

.vpad-mode-overlay:active {
  opacity: 0.85 !important;
}

/* Authentic GBA Console Chassis Body */
.gba-chassis-body {
  width: 100%;
  background: linear-gradient(180deg, #3730a3 0%, #29247d 45%, #1e1b4b 100%);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 28px;
  box-shadow: 
    0 20px 45px rgba(0, 0, 0, 0.85),
    inset 0 2px 3px rgba(255, 255, 255, 0.25),
    inset 0 -4px 10px rgba(0, 0, 0, 0.6);
  padding: 1.25rem 1.5rem 1.75rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  position: relative;
  overflow: hidden;
}

/* Subtle textured contour lines on sides */
.gba-chassis-body::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 12px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.08), transparent);
  pointer-events: none;
}

.gba-chassis-body::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  width: 12px;
  background: linear-gradient(-90deg, rgba(255, 255, 255, 0.08), transparent);
  pointer-events: none;
}

/* ==========================================================================
   1. Shoulder Triggers (L & R) and Center Utility Pills
   ========================================================================== */
.gba-shoulders-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0 0.5rem;
}

/* Ergonomic GBA Shoulder Buttons */
.gba-shoulder-btn {
  background: linear-gradient(180deg, #e2e8f0 0%, #cbd5e1 50%, #94a3b8 100%);
  border: 1px solid rgba(255, 255, 255, 0.6);
  color: #334155;
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: 1px;
  width: 110px;
  height: 44px;
  border-radius: 22px;
  cursor: pointer;
  box-shadow: 
    0 6px 12px rgba(0, 0, 0, 0.5),
    inset 0 2px 2px rgba(255, 255, 255, 0.8),
    inset 0 -2px 4px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.08s ease;
  touch-action: manipulation;
}

.shoulder-l {
  border-top-left-radius: 26px;
  border-bottom-left-radius: 12px;
}

.shoulder-r {
  border-top-right-radius: 26px;
  border-bottom-right-radius: 12px;
}

.gba-shoulder-btn:active,
.gba-shoulder-btn.pressed {
  transform: translateY(3px) scale(0.97);
  box-shadow: 
    0 2px 4px rgba(0, 0, 0, 0.6),
    inset 0 2px 4px rgba(0, 0, 0, 0.4);
  filter: brightness(0.9);
}

/* Center Utility Pills (Turbo & Menu) */
.gba-center-pills {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.gba-pill-quick {
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #e2e8f0;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.62rem;
  padding: 0.45rem 0.85rem;
  border-radius: 9999px;
  cursor: pointer;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4), inset 0 1px 1px rgba(255, 255, 255, 0.1);
  transition: all 0.12s ease;
  touch-action: manipulation;
}

.gba-pill-quick:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.3);
}

.gba-pill-quick.active {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #000;
  border-color: #fbbf24;
  box-shadow: 0 0 15px rgba(245, 158, 11, 0.6);
  font-weight: 700;
}

/* ==========================================================================
   2. Main Controls Face (D-Pad, Start/Select, Actions)
   ========================================================================== */
.gba-controls-face {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.5rem 0.75rem;
}

/* --------------------------------------------------------------------------
   D-Pad (Cruz Direcional GBA Clássica)
   -------------------------------------------------------------------------- */
.gba-dpad-wrapper {
  position: relative;
  width: 170px;
  height: 170px;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none; /* Prevents scroll during D-Pad sliding */
}

/* Outer circular bezel around D-Pad (authentic to GBA case indentation) */
.gba-dpad-wrapper::before {
  content: "";
  position: absolute;
  width: 164px;
  height: 164px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 0, 0, 0.4) 60%, rgba(255, 255, 255, 0.05) 100%);
  box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.8), 0 1px 1px rgba(255, 255, 255, 0.15);
}

.gba-dpad-cross {
  position: relative;
  width: 140px;
  height: 140px;
  z-index: 2;
}

/* Center pivot circle */
.gba-dpad-pivot {
  position: absolute;
  top: 48px;
  left: 48px;
  width: 44px;
  height: 44px;
  background: #1e222d;
  border-radius: 50%;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.7);
  z-index: 4;
  pointer-events: none;
}

.gba-dpad-pivot::after {
  content: "";
  position: absolute;
  top: 14px;
  left: 14px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle, #11141c 40%, #2d3342 100%);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.9);
}

/* D-Pad Arms */
.gba-dpad-arm {
  position: absolute;
  background: linear-gradient(145deg, #2b3240 0%, #1a1e28 100%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
  box-shadow: 
    0 4px 10px rgba(0, 0, 0, 0.6),
    inset 0 1px 1px rgba(255, 255, 255, 0.18);
  transition: all 0.08s ease;
  touch-action: none;
}

.dpad-arrow {
  color: #64748b;
  font-size: 0.95rem;
  pointer-events: none;
  filter: drop-shadow(0 -1px 0 rgba(0, 0, 0, 0.8));
  transition: color 0.08s ease;
}

.dpad-up {
  top: 0;
  left: 48px;
  width: 44px;
  height: 52px;
  border-radius: 10px 10px 0 0;
  padding-bottom: 8px;
}

.dpad-down {
  bottom: 0;
  left: 48px;
  width: 44px;
  height: 52px;
  border-radius: 0 0 10px 10px;
  padding-top: 8px;
}

.dpad-left {
  top: 48px;
  left: 0;
  width: 52px;
  height: 44px;
  border-radius: 10px 0 0 10px;
  padding-right: 8px;
}

.dpad-right {
  top: 48px;
  right: 0;
  width: 52px;
  height: 44px;
  border-radius: 0 10px 10px 0;
  padding-left: 8px;
}

.gba-dpad-arm:active,
.gba-dpad-arm.pressed {
  background: linear-gradient(145deg, #6366f1 0%, #4338ca 100%);
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.8);
  transform: scale(0.96);
}

.gba-dpad-arm.pressed .dpad-arrow {
  color: #fff;
}

/* --------------------------------------------------------------------------
   Center Controls (SELECT & START Rubber Pills)
   -------------------------------------------------------------------------- */
.gba-center-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  margin-top: 55px; /* lower positioning like real GBA */
}

.gba-pill-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}

/* Angled rubber button */
.gba-pill-rubber {
  width: 44px;
  height: 16px;
  background: linear-gradient(135deg, #475569 0%, #1e293b 100%);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  cursor: pointer;
  transform: rotate(-25deg);
  box-shadow: 
    0 4px 6px rgba(0, 0, 0, 0.5),
    inset 0 1px 1px rgba(255, 255, 255, 0.25);
  transition: all 0.08s ease;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}

.pill-groove {
  width: 20px;
  height: 2px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 1px;
}

.gba-pill-rubber:active,
.gba-pill-rubber.pressed {
  transform: rotate(-25deg) translateY(2px) scale(0.95);
  background: #334155;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.6), inset 0 2px 3px rgba(0, 0, 0, 0.7);
}

.gba-pill-label {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.52rem;
  color: rgba(255, 255, 255, 0.45);
  letter-spacing: 0.5px;
  transform: rotate(-25deg);
  user-select: none;
}

/* --------------------------------------------------------------------------
   Action Buttons (A & B Angled GBA Style)
   -------------------------------------------------------------------------- */
.gba-actions-wrapper {
  position: relative;
  width: 170px;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Oval chassis depression around A and B */
.gba-actions-wrapper::before {
  content: "";
  position: absolute;
  width: 155px;
  height: 95px;
  border-radius: 50px;
  background: radial-gradient(ellipse, rgba(0, 0, 0, 0.35) 60%, rgba(255, 255, 255, 0.04) 100%);
  transform: rotate(-26deg);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.8), 0 1px 1px rgba(255, 255, 255, 0.12);
}

.gba-action-group {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  z-index: 2;
}

/* B Button (Lower Left) */
.group-b {
  bottom: 8px;
  left: 12px;
}

/* A Button (Upper Right) */
.group-a {
  top: 8px;
  right: 12px;
}

.gba-action-round {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: #fff;
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 1.45rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 
    0 8px 18px rgba(0, 0, 0, 0.6),
    inset 0 3px 3px rgba(255, 255, 255, 0.4),
    inset 0 -3px 6px rgba(0, 0, 0, 0.4);
  transition: transform 0.08s ease, filter 0.08s ease, box-shadow 0.08s ease;
  touch-action: manipulation;
}

/* B Button: GBA Iconic Dark Purple */
.btn-b {
  background: linear-gradient(145deg, #6366f1 0%, #4338ca 55%, #312e81 100%);
}

/* A Button: GBA Iconic Burgundy / Crimson */
.btn-a {
  background: linear-gradient(145deg, #ef4444 0%, #b91c1c 55%, #7f1d1d 100%);
}

.gba-action-round:active,
.gba-action-round.pressed {
  transform: translateY(3px) scale(0.94);
  box-shadow: 
    0 2px 5px rgba(0, 0, 0, 0.7),
    inset 0 2px 5px rgba(0, 0, 0, 0.8);
  filter: brightness(1.2);
}

.gba-action-label {
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.4);
  letter-spacing: 1px;
}

/* --------------------------------------------------------------------------
   3. Chassis Footer & Speaker Grille
   -------------------------------------------------------------------------- */
.gba-chassis-footer {
  display: flex;
  justify-content: flex-end;
  padding: 0 1rem;
}

.gba-speaker-holes {
  display: grid;
  grid-template-columns: repeat(3, 6px);
  gap: 5px;
}

.gba-speaker-holes span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #11141c;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.9), 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* ==========================================================================
   4. Mobile Portrait Handheld Fusion (True Handheld GBA Experience)
   ========================================================================== */
@media (max-width: 768px) {
  #virtual-pad-container {
    max-width: 100%;
    margin-top: 0;
  }

  .gba-chassis-body {
    border-radius: 0 0 28px 28px;
    border-top: none;
    padding: 0.75rem 0.5rem 1.5rem 0.5rem;
    gap: 0.75rem;
  }

  .gba-shoulder-btn {
    width: 85px;
    height: 38px;
    font-size: 1rem;
  }

  .gba-center-pills {
    gap: 0.35rem;
  }

  .gba-pill-quick {
    font-size: 0.54rem;
    padding: 0.35rem 0.55rem;
  }

  .gba-dpad-wrapper {
    width: 140px;
    height: 140px;
  }

  .gba-dpad-wrapper::before {
    width: 135px;
    height: 135px;
  }

  .gba-dpad-cross {
    width: 120px;
    height: 120px;
  }

  .gba-dpad-arm {
    width: 38px;
    height: 44px;
  }

  .dpad-up {
    top: 0;
    left: 41px;
    width: 38px;
    height: 44px;
  }

  .dpad-down {
    bottom: 0;
    left: 41px;
    width: 38px;
    height: 44px;
  }

  .dpad-left {
    top: 41px;
    left: 0;
    width: 44px;
    height: 38px;
  }

  .dpad-right {
    top: 41px;
    right: 0;
    width: 44px;
    height: 38px;
  }

  .gba-dpad-pivot {
    top: 41px;
    left: 41px;
    width: 38px;
    height: 38px;
  }

  .gba-actions-wrapper {
    width: 140px;
    height: 125px;
  }

  .gba-actions-wrapper::before {
    width: 130px;
    height: 80px;
  }

  .gba-action-round {
    width: 52px;
    height: 52px;
    font-size: 1.25rem;
  }

  .gba-center-controls {
    gap: 1rem;
    margin-top: 40px;
  }

  .gba-pill-rubber {
    width: 36px;
    height: 14px;
  }
}
