/* ============================================================================
 * Xbox / Standard Gamepad Controls & HUD Prompts (ARPG HD style)
 * - Virtual UI Cursor for Inventory / Stash / Vendor / Skill / Character panels
 * - Contextual [A] Loot / Talk / Use floating action prompt
 * - Color-coded Xbox button badges (A green, B red, X blue, Y gold, LB/RB/LT/RT)
 * - Xbox Controller Guide Modal
 * ============================================================================ */

/* Color-coded Xbox button pills */
.xb-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  font: 800 9.5px/1 var(--font-ui);
  letter-spacing: 0.2px;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
  pointer-events: none;
}
.xb-badge.xb-a  { background: radial-gradient(circle at 35% 30%, #3ecf5e, #197a2f); border-color: #7ef095; }
.xb-badge.xb-b  { background: radial-gradient(circle at 35% 30%, #e84848, #8c1b1b); border-color: #ff9292; }
.xb-badge.xb-x  { background: radial-gradient(circle at 35% 30%, #3d8ef5, #184b96); border-color: #8bc1ff; }
.xb-badge.xb-y  { background: radial-gradient(circle at 35% 30%, #f0be32, #996e08); border-color: #ffe68c; color: #fffdf5; }
.xb-badge.xb-rb,
.xb-badge.xb-lb,
.xb-badge.xb-rt,
.xb-badge.xb-lt {
  border-radius: 4px;
  min-width: 20px;
  height: 15px;
  padding: 0 4px;
  font-size: 9px;
  background: linear-gradient(180deg, #3a352e, #1a1714);
  border-color: #cbb07a;
  color: #f6e3b4;
}
.xb-badge.xb-dpad {
  border-radius: 3px;
  min-width: 15px;
  height: 15px;
  padding: 0 3px;
  font-size: 9px;
  background: rgba(24, 20, 16, 0.92);
  border-color: #9e8455;
  color: #ebd5a0;
}

/* HUD badge placement when Xbox controller is active */
.ui-skill-btn .xb-hud-tag {
  position: absolute;
  left: 3px;
  top: 3px;
  z-index: 3;
}
.qsk-slot .xb-hud-tag {
  position: absolute;
  left: 2px;
  top: 2px;
  z-index: 3;
}
.belt-cell .xb-hud-tag {
  position: absolute;
  left: 3px;
  bottom: 2px;
  z-index: 3;
}

/* Contextual [A] Interact / Loot Floating Prompt above HUD */
#gp-action-prompt {
  position: fixed;
  left: 50%;
  bottom: calc(222px * var(--hud-scale, 1));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px;
  background: linear-gradient(180deg, rgba(24, 18, 12, 0.94), rgba(10, 8, 5, 0.96));
  border: 1px solid #c9a65b;
  border-radius: 999px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.9), 0 0 12px rgba(214, 175, 92, 0.24);
  color: #f4e3b2;
  font: 600 12.5px/1.2 var(--font-title);
  letter-spacing: 0.4px;
  z-index: 15;
  pointer-events: none;
}
#gp-action-prompt[hidden] {
  display: none !important;
}
#gp-action-prompt .xb-badge {
  width: 20px;
  height: 20px;
  font-size: 11px;
}

/* Hidden virtual pointer anchor + ARPG Console Cell Snap Focus Frame & Bottom Button Legend */
#gp-virtual-cursor {
  position: fixed;
  left: 50%;
  top: 50%;
  width: 1px;
  height: 1px;
  pointer-events: none;
  z-index: 9999;
}
#gp-virtual-cursor[hidden],
#gp-virtual-cursor .gp-cur-ring,
#gp-virtual-cursor .gp-cur-hints {
  display: none !important;
}

#gp-focus-frame {
  position: fixed;
  left: 0;
  top: 0;
  width: 48px;
  height: 48px;
  box-sizing: border-box;
  border: 2px solid #ffe08a;
  border-radius: 3px;
  box-shadow:
    0 0 12px rgba(255, 208, 96, 0.8),
    inset 0 0 8px rgba(255, 224, 138, 0.32);
  background: rgba(255, 218, 120, 0.08);
  pointer-events: none;
  z-index: 29;
  transition:
    left 0.05s ease-out,
    top 0.05s ease-out,
    width 0.05s ease-out,
    height 0.05s ease-out;
}
#gp-focus-frame[hidden] {
  display: none !important;
}

#gp-legend {
  position: fixed;
  left: 50%;
  bottom: max(8px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: 6px 16px;
  padding: 6px 16px;
  max-width: calc(100vw - 24px);
  background: linear-gradient(180deg, rgba(22, 16, 11, 0.95), rgba(8, 6, 4, 0.97));
  border: 1px solid #8c7146;
  border-radius: 4px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.92), inset 0 0 12px rgba(180, 140, 70, 0.1);
  color: #e4d2a8;
  font: 12.5px/1.15 var(--font-title);
  letter-spacing: 0.3px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 40;
}
#gp-legend[hidden] {
  display: none !important;
}
#gp-legend > span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.gp-hold-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  border-radius: 999px;
  background: conic-gradient(#ffd978 var(--gp-hold, 0deg), transparent 0deg);
}
body.mobile-mode #gp-legend .gp-leg-opt {
  display: none !important;
}
@media (max-width: 900px), (max-height: 460px) {
  #gp-legend .gp-leg-opt {
    display: none !important;
  }
  #gp-legend {
    padding: 4px 12px;
    gap: 4px 12px;
    font-size: 11.5px;
  }
}

/* D-Pad focus highlight inside NPC Dialog & Waypoint lists */
.gp-focus {
  outline: 2px solid #ffd978 !important;
  outline-offset: 1px;
  box-shadow: 0 0 14px rgba(255, 208, 96, 0.55) !important;
  filter: brightness(1.15);
}

/* Xbox Controller Guide Modal */
.gp-guide-card {
  width: min(650px, 94vw);
  max-height: 88vh;
  overflow-y: auto;
  background: linear-gradient(180deg, #1b150f 0%, #0d0a07 100%);
  border: 2px solid #9c7e4c;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.96), inset 0 0 28px rgba(180, 140, 70, 0.12);
  padding: 16px 20px;
  color: #e8d8b5;
}
.gp-guide-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 10px;
  margin-bottom: 12px;
  border-bottom: 1px solid #4d3e28;
}
.gp-guide-head h3 {
  margin: 0;
  font: 700 17px/1.2 var(--font-title);
  color: #f4dc96;
  letter-spacing: 0.8px;
}
.gp-status-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  margin-bottom: 12px;
  background: rgba(34, 26, 16, 0.72);
  border: 1px solid #5c4a30;
  font-size: 12.5px;
}
.gp-status-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 6px;
  background: #7c705d;
}
.gp-status-dot.on {
  background: #4ce870;
  box-shadow: 0 0 8px #4ce870;
}
.gp-guide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(275px, 1fr));
  gap: 8px 14px;
}
.gp-map-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 8px;
  background: rgba(22, 17, 12, 0.78);
  border: 1px solid #3c3020;
  font-size: 12px;
}
.gp-map-keys {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 72px;
  flex-shrink: 0;
}
.gp-map-desc {
  color: #dfd0ae;
  line-height: 1.28;
}

/* When a Bluetooth Xbox controller is active on mobile/tablet, hide touch overlay and show ARPG HUD bar */
body.mobile-mode.gamepad-mode #mobile-ui {
  display: none !important;
}
body.gamepad-mode #btn-autofollow {
  opacity: 0.58;
}
