/* ==========================================================================
   ALEXROJASGAMES GBA PRO HORIZONTAL — SISTEMA DE DISEÑO PROPIO
   ========================================================================== */

:root,
[data-theme="cyber-neon"] {
  --theme-name: "Cyber-Neon";
  --bg-void: #08090e;
  --bg-surface: rgba(0, 22, 34, 0.65);
  --bg-elevated: rgba(0, 38, 56, 0.75);
  --shell-bg: linear-gradient(145deg, rgba(12, 22, 34, 0.95) 0%, rgba(6, 12, 20, 0.98) 50%, rgba(10, 26, 38, 0.95) 100%);
  --shell-border: #00FFFF;
  --shell-glow: 0 0 32px rgba(0, 255, 255, 0.28), 0 24px 65px rgba(0, 0, 0, 0.8), inset 0 1px 2px rgba(0, 255, 255, 0.35);
  --bezel-bg: #04060a;
  --bezel-border: rgba(0, 255, 255, 0.38);
  --primary: #00FFFF;
  --primary-dim: rgba(0, 255, 255, 0.14);
  --primary-glow: 0 0 14px rgba(0, 255, 255, 0.55);
  --secondary: #FF007F;
  --accent: #38BDF8;
  --text-main: #F8FAFC;
  --text-muted: #94A3B8;
  --card-border: rgba(0, 255, 255, 0.28);
  --btn-dpad: linear-gradient(145deg, #131c29, #0b1018);
  --btn-dpad-border: rgba(0, 255, 255, 0.45);
  --btn-a: linear-gradient(145deg, #00FFFF, #0099B8);
  --btn-a-text: #041014;
  --btn-b: linear-gradient(145deg, #FF007F, #B80058);
  --btn-b-text: #FFFFFF;
  --btn-shoulder: linear-gradient(180deg, rgba(0, 255, 255, 0.22), rgba(10, 20, 30, 0.92));
  --font-display: 'Orbitron', sans-serif;
  --font-body: 'Exo 2', sans-serif;
  --glass-blur: 20px;
  --circuit-opacity: 0.05;
}

/* 2. ESMERALDA OLED */
[data-theme="emerald-oled"] {
  --theme-name: "Esmeralda OLED";
  --bg-void: #020805;
  --bg-surface: rgba(4, 26, 16, 0.72);
  --bg-elevated: rgba(8, 42, 26, 0.8);
  --shell-bg: linear-gradient(145deg, #062819 0%, #03140c 55%, #083320 100%);
  --shell-border: #00FF88;
  --shell-glow: 0 0 32px rgba(0, 255, 136, 0.28), 0 20px 60px rgba(0, 0, 0, 0.85), inset 0 1px 2px rgba(250, 204, 21, 0.4);
  --bezel-bg: #010503;
  --bezel-border: rgba(250, 204, 21, 0.45);
  --primary: #00FF88;
  --primary-dim: rgba(0, 255, 136, 0.14);
  --primary-glow: 0 0 15px rgba(0, 255, 136, 0.55);
  --secondary: #FACC15;
  --accent: #EF4444;
  --text-main: #ECFDF5;
  --text-muted: #6EE7B7;
  --card-border: rgba(0, 255, 136, 0.3);
  --btn-dpad: linear-gradient(145deg, #0c291c, #05140d);
  --btn-dpad-border: rgba(250, 204, 21, 0.5);
  --btn-a: linear-gradient(145deg, #00FF88, #059669);
  --btn-a-text: #02140b;
  --btn-b: linear-gradient(145deg, #FACC15, #CA8A04);
  --btn-b-text: #090d06;
  --btn-shoulder: linear-gradient(180deg, rgba(0, 255, 136, 0.22), rgba(4, 24, 15, 0.92));
  --font-display: 'Russo One', 'Orbitron', sans-serif;
  --font-body: 'Chakra Petch', 'Exo 2', sans-serif;
  --glass-blur: 18px;
  --circuit-opacity: 0.08;
}

/* 3. VIOLETA CRISTAL */
[data-theme="atomic-purple"] {
  --theme-name: "Violeta Cristal";
  --bg-void: #0d0718;
  --bg-surface: rgba(46, 16, 101, 0.45);
  --bg-elevated: rgba(76, 29, 149, 0.52);
  --shell-bg: linear-gradient(135deg, rgba(109, 40, 217, 0.56) 0%, rgba(59, 7, 100, 0.68) 50%, rgba(126, 34, 206, 0.52) 100%);
  --shell-border: #C084FC;
  --shell-glow: 0 0 35px rgba(192, 132, 252, 0.3), 0 24px 60px rgba(0, 0, 0, 0.8), inset 0 0 35px rgba(216, 180, 254, 0.2);
  --bezel-bg: #110b1d;
  --bezel-border: rgba(192, 132, 252, 0.45);
  --primary: #C084FC;
  --primary-dim: rgba(192, 132, 252, 0.16);
  --primary-glow: 0 0 16px rgba(192, 132, 252, 0.6);
  --secondary: #F43F5E;
  --accent: #38BDF8;
  --text-main: #FAF5FF;
  --text-muted: #D8B4FE;
  --card-border: rgba(192, 132, 252, 0.32);
  --btn-dpad: linear-gradient(145deg, #27173a, #170d24);
  --btn-dpad-border: rgba(216, 180, 254, 0.4);
  --btn-a: linear-gradient(145deg, #F43F5E, #BE123C);
  --btn-a-text: #FFFFFF;
  --btn-b: linear-gradient(145deg, #A855F7, #6B21A8);
  --btn-b-text: #FFFFFF;
  --btn-shoulder: linear-gradient(180deg, rgba(192, 132, 252, 0.3), rgba(46, 16, 101, 0.85));
  --font-display: 'Orbitron', sans-serif;
  --font-body: 'Chakra Petch', sans-serif;
  --glass-blur: 14px;
  --circuit-opacity: 0.22;
}

/* 4. TITANIO OSCURO */
[data-theme="titanium-spatial"] {
  --theme-name: "Titanio Oscuro";
  --bg-void: #09090b;
  --bg-surface: rgba(255, 255, 255, 0.06);
  --bg-elevated: rgba(255, 255, 255, 0.1);
  --shell-bg: linear-gradient(145deg, rgba(39, 39, 42, 0.9) 0%, rgba(24, 24, 27, 0.95) 50%, rgba(52, 52, 58, 0.9) 100%);
  --shell-border: rgba(255, 255, 255, 0.28);
  --shell-glow: 0 25px 70px rgba(0, 0, 0, 0.85), inset 0 1px 1px rgba(255, 255, 255, 0.45);
  --bezel-bg: #000000;
  --bezel-border: rgba(255, 255, 255, 0.16);
  --primary: #38BDF8;
  --primary-dim: rgba(56, 189, 248, 0.15);
  --primary-glow: 0 0 18px rgba(56, 189, 248, 0.45);
  --secondary: #818CF8;
  --accent: #F472B6;
  --text-main: #FAFAFA;
  --text-muted: #A1A1AA;
  --card-border: rgba(255, 255, 255, 0.16);
  --btn-dpad: linear-gradient(145deg, #27272a, #18181b);
  --btn-dpad-border: rgba(255, 255, 255, 0.24);
  --btn-a: linear-gradient(145deg, #38BDF8, #0284C7);
  --btn-a-text: #04131d;
  --btn-b: linear-gradient(145deg, #52525B, #27272A);
  --btn-b-text: #FAFAFA;
  --btn-shoulder: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(39, 39, 42, 0.9));
  --font-display: 'Exo 2', sans-serif;
  --font-body: 'Exo 2', sans-serif;
  --glass-blur: 40px;
  --circuit-opacity: 0.02;
}

/* 5. SYNTHWAVE 86 */
[data-theme="synthwave-outrun"] {
  --theme-name: "Synthwave 86";
  --bg-void: #0f051d;
  --bg-surface: rgba(34, 9, 64, 0.68);
  --bg-elevated: rgba(56, 14, 98, 0.78);
  --shell-bg: linear-gradient(160deg, #240b47 0%, #120428 50%, #3b0d54 100%);
  --shell-border: #FF006E;
  --shell-glow: 0 0 32px rgba(255, 0, 110, 0.4), 0 0 65px rgba(0, 240, 255, 0.2), inset 0 1px 2px rgba(255, 190, 11, 0.5);
  --bezel-bg: #080212;
  --bezel-border: #00F0FF;
  --primary: #FF006E;
  --primary-dim: rgba(255, 0, 110, 0.18);
  --primary-glow: 0 0 16px rgba(255, 0, 110, 0.65);
  --secondary: #00F0FF;
  --accent: #FFBE0B;
  --text-main: #FFF0F7;
  --text-muted: #F48FB1;
  --card-border: rgba(255, 0, 110, 0.38);
  --btn-dpad: linear-gradient(145deg, #2a0e4f, #16062c);
  --btn-dpad-border: #00F0FF;
  --btn-a: linear-gradient(145deg, #FF006E, #B5004E);
  --btn-a-text: #FFFFFF;
  --btn-b: linear-gradient(145deg, #00F0FF, #0096C7);
  --btn-b-text: #06131f;
  --btn-shoulder: linear-gradient(180deg, rgba(255, 0, 110, 0.35), rgba(24, 6, 48, 0.92));
  --font-display: 'Russo One', 'Orbitron', sans-serif;
  --font-body: 'Chakra Petch', sans-serif;
  --glass-blur: 20px;
  --circuit-opacity: 0.07;
}

/* 6. PLATA METÁLICA */
[data-theme="gba-sp-classic"] {
  --theme-name: "Plata Metálica";
  --bg-void: #0d1117;
  --bg-surface: rgba(30, 41, 59, 0.72);
  --bg-elevated: rgba(51, 65, 85, 0.8);
  --shell-bg: linear-gradient(145deg, #cbd5e1 0%, #94a3b8 35%, #64748b 75%, #94a3b8 100%);
  --shell-border: #e2e8f0;
  --shell-glow: 0 25px 60px rgba(0, 0, 0, 0.8), inset 0 2px 4px rgba(255, 255, 255, 0.85), inset 0 -4px 8px rgba(15, 23, 42, 0.5);
  --bezel-bg: #111827;
  --bezel-border: #334155;
  --primary: #38BDF8;
  --primary-dim: rgba(56, 189, 248, 0.16);
  --primary-glow: 0 0 12px rgba(56, 189, 248, 0.45);
  --secondary: #6366F1;
  --accent: #10B981;
  --text-main: #F8FAFC;
  --text-muted: #94A3B8;
  --card-border: rgba(148, 163, 184, 0.35);
  --btn-dpad: linear-gradient(145deg, #475569, #1e293b);
  --btn-dpad-border: #334155;
  --btn-a: linear-gradient(145deg, #4f46e5, #312e81);
  --btn-a-text: #FFFFFF;
  --btn-b: linear-gradient(145deg, #be123c, #881337);
  --btn-b-text: #FFFFFF;
  --btn-shoulder: linear-gradient(180deg, #e2e8f0, #94a3b8);
  --font-display: 'Orbitron', sans-serif;
  --font-body: 'Exo 2', sans-serif;
  --glass-blur: 16px;
  --circuit-opacity: 0.0;
}

/* ==========================================================================
   BASE & AMBIENT BACKGROUND
   ========================================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  min-height: 100vh;
  background-color: var(--bg-void);
  color: var(--text-main);
  font-family: var(--font-body);
  overflow-x: hidden;
  transition: background-color 0.35s ease, color 0.35s ease;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(circle at 18% 15%, var(--primary-dim) 0%, transparent 45%),
    radial-gradient(circle at 82% 85%, rgba(255, 0, 127, 0.08) 0%, transparent 45%),
    linear-gradient(180deg, rgba(0,0,0,0.2) 0%, rgba(0,0,0,0.75) 100%);
  pointer-events: none;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(to right, rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: radial-gradient(ellipse at center, rgba(0,0,0,0.85) 20%, transparent 80%);
  -webkit-mask-image: radial-gradient(ellipse at center, rgba(0,0,0,0.85) 20%, transparent 80%);
  pointer-events: none;
}

/* ==========================================================================
   GLASSMORPHISM PANELS & BUTTONS
   ========================================================================== */
.arg-panel {
  background: var(--bg-surface);
  backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.arg-panel:hover {
  border-color: var(--primary);
}

.arg-title {
  font-family: var(--font-display);
  letter-spacing: 0.06em;
}

.arg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.55rem 0.95rem;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: var(--bg-elevated);
  color: var(--text-main);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
}

.arg-btn:hover {
  border-color: var(--primary);
  box-shadow: var(--primary-glow);
  transform: translateY(-1px);
}

.arg-btn:active {
  transform: translateY(1px) scale(0.98);
}

.arg-btn-primary {
  background: var(--primary-dim);
  border-color: var(--primary);
  color: var(--primary);
}

.arg-btn-primary:hover {
  background: var(--primary);
  color: #041014;
}

/* ==========================================================================
   WIDESCREEN HORIZONTAL GBA HANDHELD CONSOLE (Nintendo Switch / Steam Deck Style)
   ========================================================================== */
.gba-horizontal-deck {
  position: relative;
  width: 100%;
  max-width: 1260px;
  margin: 0 auto;
  background: var(--shell-bg);
  border: 2.5px solid var(--shell-border);
  border-radius: 44px;
  box-shadow: var(--shell-glow);
  padding: 1.15rem 1.4rem;
  display: grid;
  grid-template-columns: 185px minmax(0, 1fr) 185px;
  gap: 1.15rem;
  align-items: stretch;
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* Translucent PCB Circuit Pattern Overlay */
.gba-horizontal-deck::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: var(--circuit-opacity);
  background-image:
    radial-gradient(circle at 12% 25%, var(--primary) 2px, transparent 2.5px),
    radial-gradient(circle at 88% 30%, var(--primary) 2px, transparent 2.5px),
    radial-gradient(circle at 15% 75%, var(--primary) 2px, transparent 2.5px),
    linear-gradient(90deg, transparent 48%, var(--primary) 49%, var(--primary) 51%, transparent 52%),
    linear-gradient(45deg, transparent 46%, var(--primary) 48%, transparent 50%);
  background-size: 95px 95px;
  pointer-events: none;
  z-index: 0;
}

.gba-horizontal-deck > * {
  position: relative;
  z-index: 1;
}

/* Left & Right Controller Grips (Wings) */
.deck-wing {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 0.35rem 0.25rem;
  border-radius: 28px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

/* Shoulder Buttons L / R */
.shoulder-btn {
  width: 100%;
  background: var(--btn-shoulder);
  border: 1.5px solid var(--shell-border);
  color: var(--text-main);
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 0.9rem;
  letter-spacing: 0.1em;
  padding: 0.65rem 1rem;
  border-radius: 22px 22px 10px 10px;
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.5), inset 0 1px 1px rgba(255, 255, 255, 0.35);
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
  touch-action: manipulation;
}

[data-theme="gba-sp-classic"] .shoulder-btn {
  color: #0f172a;
}

.shoulder-btn:active,
.shoulder-btn.pressed {
  transform: translateY(3px);
  box-shadow: 0 0 18px var(--primary), inset 0 2px 6px rgba(0, 0, 0, 0.6);
  border-color: var(--primary);
}

/* ==========================================================================
   GIANT CENTERPIECE SCREEN & SCALING MODES (3:2 Original / 16:9 Widescreen / Max)
   ========================================================================== */
.gba-screen-bezel {
  background: var(--bezel-bg);
  border: 2px solid var(--bezel-border);
  border-radius: 24px;
  padding: 0.75rem 1rem 0.85rem;
  box-shadow:
    inset 0 6px 24px rgba(0, 0, 0, 0.95),
    0 6px 26px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 360px;
}

.gba-viewport-stage {
  position: relative;
  width: 100%;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #020306;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.95);
}

/* SCALE MODE 1: 3:2 Proportional Giant (Crisp Native Ratio, Max Size) */
[data-scale="fit"] .gba-viewport-frame {
  position: relative;
  width: 100%;
  max-height: 68vh;
  aspect-ratio: 3 / 2;
  margin: 0 auto;
  overflow: hidden;
}
[data-scale="fit"] .gba-viewport-frame canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
  object-fit: contain;
}

/* SCALE MODE 2: 16:9 Widescreen Full Fill (Llena todo el ancho horizontal sin bordes) */
[data-scale="wide"] .gba-viewport-frame {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 380px;
  aspect-ratio: 16 / 9;
  overflow: hidden;
}
[data-scale="wide"] .gba-viewport-frame canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
  object-fit: fill;
}

/* SCALE MODE 3: Cinema / Ultra-Max (Masivo) */
[data-scale="max"] .gba-viewport-frame {
  position: relative;
  width: 100%;
  min-height: 480px;
  aspect-ratio: 16 / 10;
  overflow: hidden;
}
[data-scale="max"] .gba-viewport-frame canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
  object-fit: fill;
}

.gba-viewport-frame canvas {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* SHADERS */
[data-shader="pixel"] .gba-viewport-frame canvas {
  image-rendering: pixelated;
  filter: none;
}

[data-shader="crt"] .gba-viewport-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(
      0deg,
      rgba(0, 0, 0, 0.32) 0px,
      rgba(0, 0, 0, 0.32) 1px,
      transparent 1px,
      transparent 3px
    ),
    radial-gradient(circle at center, transparent 60%, rgba(0, 0, 0, 0.55) 100%);
  pointer-events: none;
  z-index: 10;
}
[data-shader="crt"] .gba-viewport-frame canvas {
  filter: contrast(1.12) saturate(1.18) brightness(1.05);
}

[data-shader="lcd"] .gba-viewport-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, rgba(0, 0, 0, 0.24) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(0, 0, 0, 0.24) 1px, transparent 1px);
  background-size: 3px 3px;
  pointer-events: none;
  z-index: 10;
}
[data-shader="lcd"] .gba-viewport-frame canvas {
  filter: contrast(1.04) sepia(0.06);
}

[data-shader="vibrant"] .gba-viewport-frame canvas {
  filter: saturate(1.42) contrast(1.14) brightness(1.06);
}

/* Power / Turbo LED */
.led-indicator {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #10B981;
  box-shadow: 0 0 10px #10B981, 0 0 4px #FFFFFF;
  display: inline-block;
}

.led-indicator.turbo-active {
  background: #F59E0B;
  box-shadow: 0 0 12px #F59E0B, 0 0 5px #FFFFFF;
  animation: pulse-led 0.5s infinite alternate;
}

@keyframes pulse-led {
  from { opacity: 0.65; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1.15); }
}

/* ==========================================================================
   ERGONOMIC D-PAD + ACTION BUTTONS
   ========================================================================== */
.dpad-cluster {
  position: relative;
  width: 146px;
  height: 146px;
  touch-action: none;
  user-select: none;
}

.dpad-btn {
  position: absolute;
  background: var(--btn-dpad);
  border: 1.5px solid var(--btn-dpad-border);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 5px 12px rgba(0, 0, 0, 0.55), inset 0 1px 1px rgba(255, 255, 255, 0.14);
  transition: transform 0.06s ease, background 0.1s ease, box-shadow 0.1s ease;
  touch-action: none;
}

.dpad-btn:active,
.dpad-btn.pressed {
  background: var(--primary-dim);
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: 0 0 16px var(--primary), inset 0 2px 5px rgba(0, 0, 0, 0.7);
}

.dpad-up {
  top: 0; left: 48px; width: 50px; height: 50px;
  border-radius: 12px 12px 4px 4px;
}
.dpad-down {
  bottom: 0; left: 48px; width: 50px; height: 50px;
  border-radius: 4px 4px 12px 12px;
}
.dpad-left {
  top: 48px; left: 0; width: 50px; height: 50px;
  border-radius: 12px 4px 4px 12px;
}
.dpad-right {
  top: 48px; right: 0; width: 50px; height: 50px;
  border-radius: 4px 12px 12px 4px;
}
.dpad-center {
  position: absolute;
  top: 49px; left: 49px; width: 48px; height: 48px;
  background: var(--btn-dpad);
  border-radius: 6px;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.dpad-center::after {
  content: "";
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, rgba(255,255,255,0.12), rgba(0,0,0,0.55));
}

.action-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 1.35rem;
  border: 2px solid rgba(255, 255, 255, 0.35);
  box-shadow:
    0 7px 16px rgba(0, 0, 0, 0.65),
    inset 0 2px 4px rgba(255, 255, 255, 0.45),
    inset 0 -3px 6px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.06s ease, box-shadow 0.06s ease;
  touch-action: none;
  user-select: none;
}

.action-btn-a {
  background: var(--btn-a);
  color: var(--btn-a-text);
}

.action-btn-b {
  background: var(--btn-b);
  color: var(--btn-b-text);
}

.action-btn:active,
.action-btn.pressed {
  transform: translateY(3px) scale(0.94);
  box-shadow: 0 0 22px var(--primary), inset 0 3px 6px rgba(0, 0, 0, 0.5);
}

.pill-btn {
  width: 100%;
  padding: 0.48rem 0.9rem;
  border-radius: 999px;
  background: var(--btn-dpad);
  border: 1.5px solid var(--btn-dpad-border);
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.5), inset 0 1px 1px rgba(255, 255, 255, 0.15);
  transition: all 0.08s ease;
  touch-action: manipulation;
}

.pill-btn:active,
.pill-btn.pressed {
  transform: translateY(2px);
  color: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 0 12px var(--primary);
}

.speaker-grille {
  display: flex;
  gap: 5px;
  align-items: center;
  justify-content: center;
}
.speaker-slot {
  width: 4px;
  height: 18px;
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.65);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.9), 0 1px 0 rgba(255,255,255,0.12);
  transform: rotate(-20deg);
}

/* Theme Cards */
.theme-swatch-card {
  position: relative;
  padding: 0.65rem 0.75rem;
  border-radius: 12px;
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.38);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.theme-swatch-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
}

.theme-swatch-card.active {
  border-color: var(--primary);
  background: var(--primary-dim);
  box-shadow: var(--primary-glow);
}

/* ==========================================================================
   MODO SWITCH / HANDHELD FULLSCREEN (Oculta paneles inferiores y maximiza consola)
   ========================================================================== */
body.handheld-only-mode header,
body.handheld-only-mode #lower-control-docks,
body.handheld-only-mode footer {
  display: none !important;
}

body.handheld-only-mode main {
  padding: 0.4rem !important;
  height: 100vh !important;
  max-width: 100vw !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

body.handheld-only-mode .gba-horizontal-deck {
  max-width: 99vw;
  height: 96vh;
  border-radius: 32px;
}

/* Botón Reactivo Inteligente para Salir de Pantalla Completa */
#btn-exit-handheld {
  display: none !important;
  position: fixed;
  top: 12px;
  left: 50%;
  z-index: 9999;
  opacity: 0 !important;
  transform: translate(-50%, -150%) !important;
  pointer-events: none !important;
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease, box-shadow 0.25s ease;
  will-change: transform, opacity;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8), 0 0 20px var(--primary-glow);
}

body.handheld-only-mode #btn-exit-handheld {
  display: inline-flex !important;
}

body.handheld-only-mode #btn-exit-handheld.is-visible {
  opacity: 1 !important;
  transform: translate(-50%, 0) !important;
  pointer-events: auto !important;
}

body.handheld-only-mode #btn-exit-handheld.is-visible:hover {
  transform: translate(-50%, 1px) scale(1.03) !important;
}



/* ==========================================================================
   RESPONSIVE: MOVILES EN HORIZONTAL (LANDSCAPE) Y VERTICAL (PORTRAIT)
   ========================================================================== */
@media (max-width: 920px) and (orientation: landscape) {
  .gba-horizontal-deck {
    grid-template-columns: 145px minmax(0, 1fr) 145px;
    padding: 0.55rem 0.75rem;
    gap: 0.6rem;
    border-radius: 28px;
  }
  .gba-screen-bezel {
    min-height: 220px;
    padding: 0.45rem 0.6rem;
  }
  .dpad-cluster {
    width: 120px;
    height: 120px;
  }
  .dpad-up, .dpad-down { left: 39px; width: 42px; height: 42px; }
  .dpad-left, .dpad-right { top: 39px; width: 42px; height: 42px; }
  .dpad-center { top: 40px; left: 40px; width: 40px; height: 40px; }
  .action-btn {
    width: 52px;
    height: 52px;
    font-size: 1.15rem;
  }
}

@media (max-width: 767px) {
  /* Mayor tamaño de letra en móvil para óptima legibilidad */
  body {
    font-size: 15px;
  }
  .arg-btn {
    font-size: 0.88rem;
    padding: 0.65rem 1rem;
  }
}

@media (max-width: 767px) and (orientation: portrait) {
  .gba-horizontal-deck {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "screen screen"
      "leftwing rightwing";
    padding: 0.85rem;
    gap: 0.85rem;
    border-radius: 28px;
  }
  .deck-screen-center {
    grid-area: screen;
  }
  .deck-wing-left {
    grid-area: leftwing;
    padding: 0.75rem 0.5rem;
  }
  .deck-wing-right {
    grid-area: rightwing;
    padding: 0.75rem 0.5rem;
  }
  .gba-screen-bezel {
    min-height: 240px;
  }
  .dpad-cluster {
    width: 130px;
    height: 130px;
  }
  .dpad-up, .dpad-down { left: 43px; width: 44px; height: 44px; }
  .dpad-left, .dpad-right { top: 43px; width: 44px; height: 44px; }
  .dpad-center { top: 44px; left: 44px; width: 42px; height: 42px; }
  .action-btn {
    width: 56px;
    height: 56px;
    font-size: 1.25rem;
  }
}


/* ==========================================================================
   MODO APP CELULAR (html.phone-app) - SIEMPRE HORIZONTAL, AJUSTE EXACTO A LA PANTALLA
   Se activa por JS solo en teléfonos (pointer: coarse y lado corto <= 600px).
   Si el teléfono está en vertical, html.force-landscape rota toda la interfaz 90°.
   La versión de PC no se ve afectada: todas las reglas cuelgan de html.phone-app.
   ========================================================================== */
#app-root {
  display: contents;
}

html.phone-app,
html.phone-app body {
  height: var(--app-h);
  overflow: hidden;
  overscroll-behavior: none;
}

html.phone-app body {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--app-w);
  min-height: 0 !important;
  display: block;
  box-sizing: border-box;
  font-size: 14px;
  padding-top: env(safe-area-inset-top);
  padding-right: env(safe-area-inset-right);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
}

/* Teléfono en vertical: se gira la interfaz 90° para que SIEMPRE se vea horizontal */
html.phone-app.force-landscape body {
  transform-origin: 0 0;
  transform: translateX(var(--app-h)) rotate(90deg);
  padding-top: env(safe-area-inset-right);
  padding-right: env(safe-area-inset-bottom);
  padding-bottom: env(safe-area-inset-left);
  padding-left: env(safe-area-inset-top);
}

html.phone-app #app-root {
  display: block;
  height: 100%;
  width: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  container-type: size;
}

/* ---- Barra superior compacta ---- */
html.phone-app header {
  height: 40px;
  overflow: hidden;
}
html.phone-app header > div {
  height: 40px;
  padding: 0 0.5rem !important;
  flex-wrap: nowrap !important;
  gap: 0.4rem !important;
  max-width: none !important;
}
html.phone-app header h1,
html.phone-app header [id="hud-status"],
html.phone-app header [data-open-keyconfig],
html.phone-app header a span {
  display: none !important;
}
html.phone-app header > div > div:last-child {
  flex-wrap: nowrap !important;
  gap: 0.3rem !important;
  overflow-x: auto;
  scrollbar-width: none;
}
html.phone-app header > div > div:last-child::-webkit-scrollbar {
  display: none;
}
html.phone-app header .arg-btn {
  font-size: 0.62rem;
  padding: 0.3rem 0.5rem;
  white-space: nowrap;
  flex-shrink: 0;
  min-height: 0;
}
html.phone-app header [data-turbo-level] {
  padding: 0.25rem 0.4rem;
}

/* ---- Consola: ocupa EXACTAMENTE el alto visible ---- */
html.phone-app main {
  padding: 0.3rem 0.4rem !important;
  gap: 0.6rem !important;
  max-width: none !important;
  flex: none !important;
}

html.phone-app .gba-horizontal-deck {
  grid-template-columns: 116px minmax(0, 1fr) 116px;
  grid-template-areas: none;
  height: calc(100cqh - 40px - 0.6rem);
  max-width: none;
  padding: 0.35rem 0.45rem;
  gap: 0.45rem;
  border-radius: 22px;
  border-width: 2px;
}
html.phone-app .gba-horizontal-deck > * {
  grid-area: auto;
  min-height: 0;
}

html.phone-app .deck-wing {
  padding: 0.25rem 0.2rem;
  border-radius: 16px;
  gap: 0.2rem;
  min-height: 0;
}
html.phone-app .deck-wing > .my-2 {
  margin-top: 0;
  margin-bottom: 0;
}
html.phone-app .shoulder-btn {
  font-size: 0.62rem;
  padding: 0.38rem 0.3rem;
  letter-spacing: 0.06em;
  border-radius: 14px 14px 8px 8px;
  line-height: 1.1;
}
html.phone-app .pill-btn {
  padding: 0.3rem 0.4rem;
  font-size: 0.58rem;
  letter-spacing: 0.06em;
}
html.phone-app .deck-wing > .w-full {
  gap: 0.3rem !important;
  padding-left: 0.2rem;
  padding-right: 0.2rem;
}
html.phone-app [id^="hint-key"] {
  display: none !important;
}

html.phone-app .dpad-cluster { width: 102px; height: 102px; }
html.phone-app .dpad-up, html.phone-app .dpad-down { left: 34px; width: 34px; height: 34px; }
html.phone-app .dpad-left, html.phone-app .dpad-right { top: 34px; width: 34px; height: 34px; }
html.phone-app .dpad-center { top: 34px; left: 34px; width: 34px; height: 34px; }
html.phone-app .action-btn {
  width: 46px;
  height: 46px;
  font-size: 1rem;
}
html.phone-app .deck-wing-right .-rotate-\[18deg\] {
  gap: 0.6rem;
}

/* ---- Marco de pantalla: sin recortes, la imagen siempre cabe completa ---- */
html.phone-app .gba-screen-bezel {
  min-height: 0;
  height: 100%;
  padding: 0.3rem 0.5rem 0.35rem;
  border-radius: 16px;
  overflow: hidden;
}
html.phone-app .gba-screen-bezel > div:first-child {
  flex-wrap: nowrap !important;
  margin-bottom: 0.25rem !important;
  gap: 0.4rem !important;
  min-width: 0;
}
html.phone-app .gba-screen-bezel > div:first-child span.truncate {
  max-width: 28vw !important;
  font-size: 0.6rem;
}
html.phone-app .gba-screen-bezel > div:first-child .arg-btn {
  font-size: 0.58rem;
  padding: 0.2rem 0.4rem;
  white-space: nowrap;
}
html.phone-app .gba-screen-bezel > div:first-child .text-\[10px\] {
  display: none;
}
html.phone-app .gba-screen-bezel > div:last-child {
  flex-wrap: nowrap !important;
  margin-top: 0.25rem !important;
  gap: 0.4rem !important;
}
html.phone-app .gba-screen-bezel > div:last-child .arg-btn {
  font-size: 0.58rem;
  padding: 0.2rem 0.4rem;
  white-space: nowrap;
}
html.phone-app .gba-screen-bezel > div:last-child span {
  font-size: 0.58rem;
  letter-spacing: 0.12em;
}

html.phone-app .gba-viewport-stage {
  flex: 1 1 0;
  min-height: 0;
  container-type: size;
  border-radius: 10px;
}
html.phone-app .gba-viewport-frame {
  min-height: 0 !important;
  max-height: none !important;
  aspect-ratio: auto !important;
}
html.phone-app[data-scale="wide"] .gba-viewport-frame {
  width: min(100cqw, calc(100cqh * 16 / 9));
  height: min(100cqh, calc(100cqw * 9 / 16));
}
html.phone-app[data-scale="fit"] .gba-viewport-frame {
  width: min(100cqw, calc(100cqh * 3 / 2));
  height: min(100cqh, calc(100cqw * 2 / 3));
}
html.phone-app[data-scale="max"] .gba-viewport-frame {
  width: min(100cqw, calc(100cqh * 16 / 10));
  height: min(100cqh, calc(100cqw * 10 / 16));
}
html.phone-app .gba-viewport-frame canvas {
  width: 100% !important;
  height: 100% !important;
}

/* ---- Paneles inferiores (ROMs, skins) se ven al deslizar hacia abajo ---- */
html.phone-app #lower-control-docks {
  grid-template-columns: 1fr;
}
html.phone-app footer {
  font-size: 0.65rem;
  padding: 0.5rem;
}

/* ---- Modo Switch (pantalla completa de la consola) en celular ---- */
html.phone-app body.handheld-only-mode main {
  height: 100cqh !important;
  padding: 0.25rem !important;
}
html.phone-app body.handheld-only-mode .gba-horizontal-deck {
  height: calc(100cqh - 0.5rem);
  max-width: none;
}



/* ==========================================================================
   AVISO INICIAL DE GIRO (vertical) + GUIA DE ROMS RESPONSIVA EN HORIZONTAL
   ========================================================================== */
.rotate-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1.1rem;
}

.rotate-copy {
  width: 100%;
}

/* Celular que gira de forma natural: vertical -> horizontal (sentido antihorario) -> pausa -> regresa */
.rotate-phone-stage {
  position: relative;
  width: 124px;
  height: 124px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.rotate-phone-stage::before {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  border: 1.5px dashed var(--primary);
  opacity: 0.28;
}
.rotate-phone {
  position: relative;
  width: 48px;
  height: 86px;
  border: 3px solid var(--primary);
  border-radius: 12px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.07), rgba(0, 0, 0, 0.55));
  box-shadow: var(--primary-glow), inset 0 0 10px rgba(0, 0, 0, 0.6);
  transform-origin: center center;
  animation: phone-turn 3.4s infinite;
}
.rotate-phone-speaker {
  position: absolute;
  top: 6px;
  left: 50%;
  width: 14px;
  height: 3px;
  margin-left: -7px;
  border-radius: 3px;
  background: var(--primary);
  opacity: 0.8;
}
.rotate-phone-screen {
  position: absolute;
  inset: 16px 5px 16px 5px;
  border-radius: 5px;
  background: linear-gradient(180deg, var(--primary-dim), rgba(0, 0, 0, 0.2));
  border: 1px solid var(--primary);
  opacity: 0.85;
}
.rotate-phone-bar {
  position: absolute;
  bottom: 5px;
  left: 50%;
  width: 16px;
  height: 3px;
  margin-left: -8px;
  border-radius: 3px;
  background: var(--primary);
  opacity: 0.55;
}

@keyframes phone-turn {
  0%, 16% {
    transform: rotate(0deg);
    animation-timing-function: cubic-bezier(0.45, 0, 0.2, 1);
  }
  44%, 72% {
    transform: rotate(-90deg);
    animation-timing-function: cubic-bezier(0.45, 0, 0.2, 1);
  }
  100% {
    transform: rotate(0deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .rotate-phone {
    animation: none;
    transform: rotate(-90deg);
  }
}

/* Aviso en horizontal (cuando el usuario ya giro el celular): distribucion compacta en fila */
@media (orientation: landscape) and (max-height: 520px) {
  #rotate-prompt-modal {
    padding: 0.5rem;
  }
  #rotate-prompt-modal .rotate-panel {
    max-width: min(620px, 94vw);
    padding: 0.9rem 1.2rem !important;
  }
  .rotate-inner {
    flex-direction: row;
    text-align: left;
    gap: 1.25rem;
  }
  .rotate-phone-stage {
    transform: scale(0.8);
    flex-shrink: 0;
    margin: -0.5rem;
  }
  #rotate-prompt-modal h2 {
    font-size: 1.15rem !important;
    margin-bottom: 0.25rem !important;
  }
  #rotate-prompt-modal p {
    font-size: 0.72rem !important;
    margin-bottom: 0.5rem !important;
  }
  #rotate-prompt-modal .rotate-tip {
    display: none;
  }
  #btn-rotate-ready {
    padding-top: 0.55rem !important;
    padding-bottom: 0.55rem !important;
    min-height: 40px !important;
  }

  /* Guia de ROMs: tres pasos en columnas para que todo quepa sin scroll */
  #rom-guide-modal {
    padding: 0.5rem;
  }
  #rom-guide-modal > div {
    max-height: 96dvh;
    max-width: min(760px, 96vw);
    padding: 0.7rem 1rem !important;
  }
  #rom-guide-modal h2 {
    font-size: 1.05rem !important;
    margin-bottom: 0.2rem !important;
  }
  #rom-guide-modal > div > p {
    font-size: 0.7rem !important;
    margin-bottom: 0.4rem !important;
  }
  #rom-guide-modal .guide-steps-grid {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 0.45rem !important;
    margin-bottom: 0.45rem !important;
  }
  #rom-guide-modal .guide-step-card {
    padding: 0.45rem !important;
    gap: 0.4rem !important;
  }
  #rom-guide-modal .guide-step-card b {
    font-size: 0.7rem !important;
  }
  #rom-guide-modal .guide-step-card div {
    font-size: 0.64rem !important;
    line-height: 1.2 !important;
  }
  #rom-guide-modal label {
    margin-bottom: 0.4rem !important;
  }
}

/* Guia de ROMs cuando la interfaz esta rotada (celular en vertical con rotacion bloqueada) */
html.force-landscape #rom-guide-modal {
  padding: 0.5rem;
}
html.force-landscape #rom-guide-modal > div {
  max-height: calc(var(--app-h) - 1rem);
  max-width: min(760px, calc(var(--app-w) - 1rem));
  padding: 0.7rem 1rem !important;
}
html.force-landscape #rom-guide-modal h2 {
  font-size: 1.05rem !important;
  margin-bottom: 0.2rem !important;
}
html.force-landscape #rom-guide-modal > div > p {
  font-size: 0.7rem !important;
  margin-bottom: 0.4rem !important;
}
html.force-landscape #rom-guide-modal .guide-steps-grid {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 0.45rem !important;
  margin-bottom: 0.45rem !important;
}
html.force-landscape #rom-guide-modal .guide-step-card {
  padding: 0.45rem !important;
  gap: 0.4rem !important;
}
html.force-landscape #rom-guide-modal .guide-step-card b {
  font-size: 0.7rem !important;
}
html.force-landscape #rom-guide-modal .guide-step-card div {
  font-size: 0.64rem !important;
  line-height: 1.2 !important;
}
html.force-landscape #rom-guide-modal label {
  margin-bottom: 0.4rem !important;
}

/* ==========================================================================
   MODO ALTO RENDIMIENTO 60 FPS (GPU COMPOSITOR OPTIMIZATION)
   Evita el re-muestreo constante de backdrop-filter y mask-image en iOS/Android
   mientras el núcleo WebGL de mGBA dibuja a 60 cuadros por segundo.
   ========================================================================== */
.gba-viewport-stage,
.gba-viewport-frame {
  contain: layout style paint;
  transform: translateZ(0);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.gba-viewport-frame canvas {
  transform: translateZ(0);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  will-change: contents;
}

body.game-running::after,
html.phone-app body::after {
  display: none !important;
}

body.game-running header,
html.phone-app header {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  background-color: rgba(5, 8, 15, 0.96) !important;
}

body.game-running .arg-panel,
html.phone-app .arg-panel {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  background-color: rgba(8, 14, 24, 0.94) !important;
}

body.game-running .gba-horizontal-deck {
  transition: none !important;
}

/* Evita que al presionar A / B / Cruceta la GPU movil recalcule sombras difuminadas (box-shadow blur)
   dentro del contenedor rotado (-18deg), usando unicamente transformacion por hardware */
.action-btn,
.dpad-btn,
.shoulder-btn,
.pill-btn {
  transition: none !important;
  will-change: transform;
}

.action-btn:active,
.action-btn.pressed {
  transform: translateY(2px) scale(0.95) !important;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.65) !important;
}

.dpad-btn:active,
.dpad-btn.pressed,
.shoulder-btn:active,
.shoulder-btn.pressed,
.pill-btn:active,
.pill-btn.pressed {
  box-shadow: none !important;
}

/* ==========================================================================
   CRUCETA FÍSICA REAL DE UNA SOLA PIEZA (MOLDED 8-WAY ROCKER D-PAD)
   Cuerpo continuo en forma de cruz (+), cavidad cóncava central para el pulgar,
   y balancín mecánico 3D que se inclina al presionar o deslizar en 8 direcciones.
   ========================================================================== */
.dpad-cluster {
  position: relative;
  width: 162px;
  height: 162px;
  cursor: pointer;
  -webkit-touch-callout: none;
  border-radius: 50%;
}

/* Cavidad circular hundida en la carcasa donde se aloja la cruceta física */
.dpad-cluster::before {
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  background: radial-gradient(
    circle at 50% 35%,
    rgba(0, 0, 0, 0.78) 0%,
    rgba(4, 8, 16, 0.92) 70%,
    rgba(255, 255, 255, 0.08) 100%
  );
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 6px 14px rgba(0, 0, 0, 0.9), 0 1px 0 rgba(255, 255, 255, 0.1);
  pointer-events: none;
  z-index: 0;
}

/* Zona táctil limpia sin desbordar hacia el borde del celular (evita toques fantasma con la palma) */
.dpad-cluster::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 50%;
}

.dpad-cluster[data-active-dir]::before {
  border-color: var(--primary);
}

/* Los 4 brazos forman UNA SOLA PIEZA en cruz: sin costuras internas entre ellos y el centro */
.dpad-btn {
  z-index: 2;
  background: linear-gradient(180deg, rgba(32, 41, 58, 0.98) 0%, rgba(15, 21, 33, 0.99) 100%);
  border: 2px solid var(--btn-dpad-border);
  color: rgba(255, 255, 255, 0.78);
  pointer-events: none !important;
  box-shadow: 0 5px 10px rgba(0, 0, 0, 0.7), inset 0 1px 1px rgba(255, 255, 255, 0.22);
}

[data-theme="gba-sp-classic"] .dpad-btn,
[data-theme="gba-sp-classic"] .dpad-center {
  background: linear-gradient(180deg, #334155 0%, #1e293b 100%);
  color: #e2e8f0;
}

.dpad-btn svg {
  width: 22px !important;
  height: 22px !important;
  pointer-events: none !important;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.7));
}

/* Brazos fusionados con el núcleo central (geometría de cruz continua de 162x162, grosor 54px) */
.dpad-up {
  top: 4px;
  left: 54px;
  width: 54px;
  height: 53px;
  border-bottom: none !important;
  border-radius: 11px 11px 0 0;
  padding-bottom: 4px;
}
.dpad-down {
  bottom: 4px;
  left: 54px;
  width: 54px;
  height: 53px;
  border-top: none !important;
  border-radius: 0 0 11px 11px;
  padding-top: 4px;
}
.dpad-left {
  top: 54px;
  left: 4px;
  width: 53px;
  height: 54px;
  border-right: none !important;
  border-radius: 11px 0 0 11px;
  padding-right: 4px;
}
.dpad-right {
  top: 54px;
  right: 4px;
  width: 53px;
  height: 54px;
  border-left: none !important;
  border-radius: 0 11px 11px 0;
  padding-left: 4px;
}

/* Núcleo central continuo de la cruz con hendidura cóncava real de pulgar */
.dpad-center {
  z-index: 3;
  top: 54px;
  left: 54px;
  width: 54px;
  height: 54px;
  background: rgba(22, 30, 45, 0.99);
  border: none !important;
  border-radius: 0;
  pointer-events: none !important;
}

/* Cavidad cóncava central (pivote físico del pulgar en una GBA real) */
.dpad-center::after {
  content: "";
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: radial-gradient(
    circle at 65% 65%,
    rgba(255, 255, 255, 0.16) 0%,
    rgba(10, 15, 26, 0.92) 58%,
    rgba(0, 0, 0, 0.98) 100%
  );
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.85);
}

/* Hundimiento mecánico del brazo presionado controlado exclusivamente por la clase .pressed */
.dpad-btn.pressed {
  background: linear-gradient(180deg, var(--primary) 0%, rgba(10, 22, 34, 0.96) 100%) !important;
  border-color: #FFFFFF !important;
  color: #FFFFFF !important;
  z-index: 4;
}
.dpad-up.pressed { transform: translateY(2px) !important; }
.dpad-down.pressed { transform: translateY(-2px) !important; }
.dpad-left.pressed { transform: translateX(2px) !important; }
.dpad-right.pressed { transform: translateX(-2px) !important; }
.dpad-btn.pressed svg {
  color: #031016 !important;
  transform: scale(1.1);
}

/* Inclinación del pivote central cóncavo sin mover la caja externa (.dpad-cluster) */
.dpad-cluster[data-active-dir="up"] .dpad-center::after { transform: translateY(-4px); border-color: var(--primary); }
.dpad-cluster[data-active-dir="down"] .dpad-center::after { transform: translateY(4px); border-color: var(--primary); }
.dpad-cluster[data-active-dir="left"] .dpad-center::after { transform: translateX(-4px); border-color: var(--primary); }
.dpad-cluster[data-active-dir="right"] .dpad-center::after { transform: translateX(4px); border-color: var(--primary); }

/* Ajuste responsivo para tablets/móviles (< 920px) */
@media (max-width: 920px) {
  .dpad-cluster { width: 132px; height: 132px; }
  .dpad-up { top: 3px; left: 44px; width: 44px; height: 43px; }
  .dpad-down { bottom: 3px; left: 44px; width: 44px; height: 43px; }
  .dpad-left { top: 44px; left: 3px; width: 43px; height: 44px; }
  .dpad-right { top: 44px; right: 3px; width: 43px; height: 44px; }
  .dpad-center { top: 44px; left: 44px; width: 44px; height: 44px; }
}

/* En celular (html.phone-app): cruceta física de una sola pieza de 112x112px dentro del ala de 116px
   (la pantalla del juego NO pierde ni un solo píxel de tamaño) */
html.phone-app .deck-wing-left {
  padding-left: 1px !important;
  padding-right: 1px !important;
}
html.phone-app .dpad-cluster {
  width: 112px !important;
  height: 112px !important;
}
html.phone-app .dpad-up {
  top: 2px !important;
  left: 37px !important;
  width: 38px !important;
  height: 37px !important;
  border-radius: 9px 9px 0 0 !important;
}
html.phone-app .dpad-down {
  bottom: 2px !important;
  left: 37px !important;
  width: 38px !important;
  height: 37px !important;
  border-radius: 0 0 9px 9px !important;
}
html.phone-app .dpad-left {
  top: 37px !important;
  left: 2px !important;
  width: 37px !important;
  height: 38px !important;
  border-radius: 9px 0 0 9px !important;
}
html.phone-app .dpad-right {
  top: 37px !important;
  right: 2px !important;
  width: 37px !important;
  height: 38px !important;
  border-radius: 0 9px 9px 0 !important;
}
html.phone-app .dpad-center {
  top: 37px !important;
  left: 37px !important;
  width: 38px !important;
  height: 38px !important;
}
html.phone-app .dpad-center::after {
  width: 21px !important;
  height: 21px !important;
}
html.phone-app .dpad-btn svg {
  width: 19px !important;
  height: 19px !important;
}

/* Modal Guardar/Cargar Perfil compacto en movil horizontal */
@media (orientation: landscape) and (max-height: 520px) {
  #profile-modal {
    padding: 0.5rem;
  }
  #profile-modal > div {
    max-height: 96dvh;
    max-width: min(720px, 96vw);
    padding: 0.75rem 1rem !important;
  }
  #profile-modal h2 {
    font-size: 1.05rem !important;
    margin-bottom: 0.3rem !important;
  }
  #profile-modal p {
    font-size: 0.68rem !important;
    line-height: 1.25 !important;
  }
}

html.force-landscape #profile-modal {
  padding: 0.5rem;
}
html.force-landscape #profile-modal > div {
  max-height: calc(var(--app-h) - 1rem);
  max-width: min(720px, calc(var(--app-w) - 1rem));
  padding: 0.75rem 1rem !important;
}
html.force-landscape #profile-modal h2 {
  font-size: 1.05rem !important;
  margin-bottom: 0.3rem !important;
}
html.force-landscape #profile-modal p {
  font-size: 0.68rem !important;
  line-height: 1.25 !important;
}

/* ==========================================================================
   RANURA DE CARTUCHO ROM INTEGRADA DENTRO DE LA PANTALLA DEL GAME BOY
   Aparece sobre el cielo estrellado y grilla 3D en espera, y se oculta al jugar.
   ========================================================================== */
.screen-change-rom-btn {
  display: none !important;
  border-color: var(--primary) !important;
  color: var(--primary) !important;
  background: var(--primary-dim) !important;
}
body.game-running .screen-change-rom-btn {
  display: inline-flex !important;
}

.screen-rom-overlay {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1rem 2.4rem;
  pointer-events: auto;
}

body.game-running .screen-rom-overlay {
  display: none !important;
}

.screen-rom-card {
  width: min(630px, 94%);
  max-height: 100%;
  background: rgba(6, 13, 24, 0.90);
  border: 2px solid var(--primary);
  border-radius: 22px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.85), 0 0 26px var(--primary-dim);
  padding: 0.95rem 1.35rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  overflow-y: auto;
}

.screen-rom-badge {
  display: inline-block;
  padding: 0.22rem 0.9rem;
  border-radius: 999px;
  background: var(--primary-dim);
  color: var(--primary);
  font-family: var(--font-display);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.screen-rom-brand {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(1.25rem, 2.9vw, 1.9rem);
  color: #FFFFFF;
  letter-spacing: 0.08em;
  line-height: 1.1;
}

.screen-rom-subtitle {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: clamp(0.68rem, 1.35vw, 0.85rem);
  color: var(--primary);
  letter-spacing: 0.08em;
  margin-bottom: 0.15rem;
}

.screen-rom-dropzone {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  padding: 0.72rem 1.05rem;
  border-radius: 14px;
  border: 2px dashed rgba(255, 255, 255, 0.34);
  background: rgba(0, 0, 0, 0.52);
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease, transform 0.15s ease;
  text-align: left;
}

.screen-rom-dropzone:hover,
.screen-rom-dropzone.is-dragging {
  border-color: var(--primary);
  background: var(--primary-dim);
  transform: translateY(-1px);
}

.screen-rom-dropzone-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary-dim);
  color: var(--primary);
  border: 1.5px solid var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.screen-rom-dropzone-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.screen-rom-dropzone-title {
  font-size: 0.9rem;
  font-weight: 800;
  color: #FFFFFF;
  line-height: 1.2;
}

.screen-rom-dropzone-hint {
  font-size: 0.74rem;
  color: #CBD5E1;
  line-height: 1.25;
}

.screen-saved-roms {
  width: 100%;
  margin-top: 0.35rem;
  padding-top: 0.55rem;
  border-top: 1px solid rgba(255, 255, 255, 0.18);
}

.screen-saved-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

/* Etiqueta ultra llamativa para "MIS CARTUCHOS GUARDADOS" */
.screen-saved-title-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.09em;
  color: #FACC15;
  background: rgba(250, 204, 21, 0.14);
  border: 1.5px solid #FACC15;
  padding: 0.22rem 0.65rem;
  border-radius: 8px;
  text-shadow: 0 0 10px rgba(250, 204, 21, 0.55);
  box-shadow: 0 0 14px rgba(250, 204, 21, 0.22);
}

.screen-saved-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #00FF88;
  box-shadow: 0 0 8px #00FF88;
  flex-shrink: 0;
}

.screen-saved-help-link {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--primary);
  text-decoration: underline;
  flex-shrink: 0;
}

.screen-saved-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 118px;
  overflow-y: auto;
  padding-right: 2px;
}

.screen-saved-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.45rem;
  border-radius: 13px;
  background: linear-gradient(90deg, rgba(0, 255, 255, 0.12) 0%, rgba(15, 23, 42, 0.85) 100%);
  border: 1.5px solid var(--primary);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.6), 0 0 12px var(--primary-dim);
  transition: transform 0.14s ease, border-color 0.14s ease, background 0.14s ease;
}

.screen-saved-item:hover {
  transform: translateY(-1px);
  background: linear-gradient(90deg, rgba(0, 255, 255, 0.22) 0%, rgba(15, 23, 42, 0.95) 100%);
}

.screen-saved-play-btn {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.25rem 0.4rem;
  text-align: left;
  cursor: pointer;
  color: #FFFFFF;
}

.screen-saved-tag {
  font-family: var(--font-display);
  font-size: 0.68rem;
  font-weight: 900;
  padding: 0.32rem 0.52rem;
  border-radius: 8px;
  background: var(--primary);
  color: #031016;
  box-shadow: 0 0 10px var(--primary-dim);
  flex-shrink: 0;
}

.screen-saved-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.screen-saved-name {
  font-size: 0.92rem;
  font-weight: 800;
  color: #FFFFFF;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.screen-saved-size {
  font-size: 0.72rem;
  font-weight: 600;
  color: #E2E8F0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.screen-saved-cta {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  padding: 0.42rem 0.85rem;
  border-radius: 9px;
  background: #00FF88;
  color: #02140A;
  box-shadow: 0 0 12px rgba(0, 255, 136, 0.45);
  flex-shrink: 0;
  transition: transform 0.12s ease, filter 0.12s ease;
}

.screen-saved-play-btn:hover .screen-saved-cta {
  transform: scale(1.04);
  filter: brightness(1.1);
}

.screen-saved-del-btn {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #CBD5E1;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.screen-saved-del-btn:hover {
  color: #FB7185;
  border-color: rgba(251, 113, 133, 0.55);
  background: rgba(251, 113, 133, 0.14);
}

/* Ajuste compacto dentro de la pantalla del Game Boy en celular horizontal (html.phone-app) */
html.phone-app .screen-rom-overlay {
  padding: 0.3rem 0.45rem 1.2rem;
}
html.phone-app .screen-rom-card {
  width: min(460px, 96%);
  padding: 0.45rem 0.65rem;
  border-radius: 14px;
  gap: 0.2rem;
}
html.phone-app .screen-rom-badge {
  font-size: 0.52rem;
  padding: 0.12rem 0.55rem;
}
html.phone-app .screen-rom-brand {
  font-size: 1.02rem;
}
html.phone-app .screen-rom-subtitle {
  font-size: 0.55rem;
  margin-bottom: 0.05rem;
}
html.phone-app .screen-rom-dropzone {
  padding: 0.36rem 0.55rem;
  gap: 0.5rem;
  border-radius: 10px;
}
html.phone-app .screen-rom-dropzone-icon {
  width: 28px;
  height: 28px;
}
html.phone-app .screen-rom-dropzone-title {
  font-size: 0.68rem;
}
html.phone-app .screen-rom-dropzone-hint {
  font-size: 0.56rem;
}
html.phone-app .screen-saved-roms {
  margin-top: 0.15rem;
  padding-top: 0.25rem;
}
html.phone-app .screen-saved-header {
  margin-bottom: 0.22rem;
}
html.phone-app .screen-saved-title-pill {
  font-size: 0.56rem;
  padding: 0.14rem 0.45rem;
}
html.phone-app .screen-saved-help-link {
  font-size: 0.56rem;
}
html.phone-app .screen-saved-list {
  max-height: 58px;
  gap: 0.22rem;
}
html.phone-app .screen-saved-item {
  padding: 0.18rem 0.35rem;
  border-radius: 9px;
}
html.phone-app .screen-saved-play-btn {
  min-height: 32px;
  padding: 0.12rem 0.25rem;
  gap: 0.4rem;
}
html.phone-app .screen-saved-tag {
  font-size: 0.54rem;
  padding: 0.18rem 0.35rem;
}
html.phone-app .screen-saved-name {
  font-size: 0.7rem;
}
html.phone-app .screen-saved-size {
  font-size: 0.55rem;
}
html.phone-app .screen-saved-cta {
  font-size: 0.56rem;
  padding: 0.22rem 0.5rem;
}
html.phone-app .screen-saved-del-btn {
  width: 26px;
  height: 26px;
}

/* En celular, ocultamos el botón Silenciar de la barra superior (ya está en el ala izquierda de la consola)
   para que MODO SWITCH se vea completo con su texto y protagonismo total */
html.phone-app header #btn-toggle-mute {
  display: none !important;
}
html.phone-app header #btn-handheld-mode {
  padding: 0.32rem 0.6rem !important;
  font-weight: 800 !important;
}

/* ==========================================================================
   BOTONES FÍSICOS DE ALTA DENSIDAD (A / B, GATILLOS L / R, START / SELECT)
   Alineados con la calidad física de la cruceta: cavidad moldeada en la carcasa,
   cúpula acrílica convexa con reflejo superior, recorrido mecánico real y
   cero cambios de sombra en vivo para conservar los 60 FPS en celular.
   ========================================================================== */

/* Cavidad diagonal moldeada en la carcasa para alojar el par B / A */
.ab-cluster {
  position: relative;
  padding: 0.55rem 0.7rem;
  border-radius: 999px;
  background: radial-gradient(
    ellipse at 50% 40%,
    rgba(0, 0, 0, 0.75) 0%,
    rgba(4, 8, 16, 0.92) 72%,
    rgba(255, 255, 255, 0.07) 100%
  );
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  box-shadow:
    inset 0 6px 14px rgba(0, 0, 0, 0.9),
    0 1px 0 rgba(255, 255, 255, 0.1);
  touch-action: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.ab-socket {
  position: relative;
  z-index: 2;
}

/* Botones A y B con densidad de botón físico moldeado (cúpula convexa + bisel inferior) */
.action-btn {
  position: relative;
  width: 66px;
  height: 66px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.48);
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 1.4rem;
  letter-spacing: 0.02em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
  box-shadow:
    0 6px 0 rgba(0, 0, 0, 0.78),
    0 9px 14px rgba(0, 0, 0, 0.65),
    inset 0 3px 5px rgba(255, 255, 255, 0.62),
    inset 0 -5px 8px rgba(0, 0, 0, 0.45) !important;
}

/* Reflejo superior tipo lente/acrílico en los botones A y B */
.action-btn::before {
  content: "";
  position: absolute;
  top: 5px;
  left: 14%;
  right: 14%;
  height: 36%;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.52) 0%, rgba(255, 255, 255, 0) 100%);
  pointer-events: none;
}

/* Hundimiento mecánico real al presionar A o B (solo usa transform para 0 costo GPU) */
.action-btn:active,
.action-btn.pressed {
  transform: translateY(4px) scale(0.95) !important;
  border-color: #FFFFFF !important;
  box-shadow:
    0 6px 0 rgba(0, 0, 0, 0.78),
    0 9px 14px rgba(0, 0, 0, 0.65),
    inset 0 3px 5px rgba(255, 255, 255, 0.62),
    inset 0 -5px 8px rgba(0, 0, 0, 0.45) !important;
}

/* Gatillos superiores L / R con cuerpo biselado y ranuras de agarre táctil */
.shoulder-btn {
  position: relative;
  border: 2px solid var(--btn-dpad-border);
  background: linear-gradient(180deg, rgba(40, 52, 74, 0.96) 0%, rgba(15, 21, 34, 0.99) 100%);
  box-shadow:
    0 5px 0 rgba(0, 0, 0, 0.8),
    0 7px 14px rgba(0, 0, 0, 0.55),
    inset 0 2px 2px rgba(255, 255, 255, 0.28),
    inset 0 -3px 5px rgba(0, 0, 0, 0.55) !important;
}

.shoulder-btn::after {
  content: "";
  display: block;
  width: 36%;
  height: 3px;
  margin: 3px auto 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  box-shadow: 0 -1px 0 rgba(0, 0, 0, 0.7);
}

.shoulder-btn:active,
.shoulder-btn.pressed {
  transform: translateY(3px) scale(0.98) !important;
  border-color: var(--primary) !important;
  color: var(--primary) !important;
  box-shadow:
    0 5px 0 rgba(0, 0, 0, 0.8),
    0 7px 14px rgba(0, 0, 0, 0.55),
    inset 0 2px 2px rgba(255, 255, 255, 0.28),
    inset 0 -3px 5px rgba(0, 0, 0, 0.55) !important;
}

/* Botones de membrana / caucho denso (SELECT, START, SILENCIAR, TURBO) alojados en bisel */
.pill-btn {
  position: relative;
  background: linear-gradient(180deg, rgba(34, 44, 62, 0.98) 0%, rgba(14, 19, 30, 0.99) 100%);
  border: 1.5px solid rgba(255, 255, 255, 0.22);
  color: #E2E8F0;
  font-weight: 800;
  box-shadow:
    0 4px 0 rgba(0, 0, 0, 0.82),
    0 6px 10px rgba(0, 0, 0, 0.55),
    inset 0 1.5px 1px rgba(255, 255, 255, 0.24),
    inset 0 -2px 4px rgba(0, 0, 0, 0.55) !important;
}

.pill-btn:active,
.pill-btn.pressed {
  transform: translateY(3px) scale(0.97) !important;
  border-color: var(--primary) !important;
  color: var(--primary) !important;
  box-shadow:
    0 4px 0 rgba(0, 0, 0, 0.82),
    0 6px 10px rgba(0, 0, 0, 0.55),
    inset 0 1.5px 1px rgba(255, 255, 255, 0.24),
    inset 0 -2px 4px rgba(0, 0, 0, 0.55) !important;
}

/* Ajuste milimétrico en celular horizontal (html.phone-app) dentro del ala derecha de 116px:
   Botones A y B más grandes y densos (50x50px) dentro de su cápsula sin tocar la pantalla del juego */
html.phone-app .deck-wing-right {
  padding-left: 1px !important;
  padding-right: 1px !important;
}
html.phone-app .ab-cluster {
  padding: 0.32rem 0.36rem !important;
  gap: 0.42rem !important;
}
html.phone-app .action-btn {
  width: 50px !important;
  height: 50px !important;
  font-size: 1.12rem !important;
}
html.phone-app .shoulder-btn {
  padding: 0.42rem 0.3rem !important;
  font-size: 0.64rem !important;
}
html.phone-app .shoulder-btn::after {
  height: 2px;
  margin-top: 2px;
}
html.phone-app .pill-btn {
  padding: 0.34rem 0.4rem !important;
  font-size: 0.58rem !important;
}
