/* ==========================================================================
   GAMESITO RETRO - THEME & VARIABLES
   ========================================================================== */
:root {
    --bg-base: #090b10;
    --bg-surface: #121622;
    --bg-card: #181d2e;
    --bg-cabinet: #1f253a;
    --border-subtle: #29324c;
    --border-glow: #3d4a70;
    
    --neon-red: #ff3366;
    --neon-red-glow: rgba(255, 51, 102, 0.4);
    --neon-blue: #00d2ff;
    --neon-blue-glow: rgba(0, 210, 255, 0.4);
    --retro-yellow: #ffb800;
    --retro-green: #00e676;
    
    --font-retro: 'Press Start 2P', monospace;
    --font-body: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    
    --shadow-cabinet: 0 16px 40px rgba(0, 0, 0, 0.7), 0 0 30px rgba(255, 51, 102, 0.15);
}

*, *::before, *::after {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100vh;
    background-color: var(--bg-base);
    background-image: 
        radial-gradient(circle at 50% 20%, rgba(255, 51, 102, 0.08) 0%, transparent 60%),
        radial-gradient(#1f2639 1px, transparent 1px);
    background-size: 100% 100%, 24px 24px;
    color: #f1f3f9;
    font-family: var(--font-body);
    user-select: none;
    -webkit-user-select: none;
    overflow-x: hidden;
}

/* ==========================================================================
   HEADER (DESKTOP)
   ========================================================================== */
.main-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 20px 8px;
    position: relative;
    z-index: 10;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.retro-icon {
    font-size: 2.2rem;
    filter: drop-shadow(0 0 10px rgba(255, 51, 102, 0.5));
    animation: pulse-icon 2.5s infinite ease-in-out;
}

@keyframes pulse-icon {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

.main-header h1 {
    font-family: var(--font-retro);
    font-size: 1.6rem;
    margin: 0;
    letter-spacing: 1px;
    color: #ffffff;
    text-shadow: 0 0 12px var(--neon-red-glow), 2px 2px 0 #000;
}

.main-header .highlight {
    color: var(--neon-red);
}

.by-totii {
    font-family: var(--font-retro);
    font-size: 0.65rem;
    color: var(--neon-blue);
    text-transform: uppercase;
    letter-spacing: 2px;
    display: block;
    margin-top: 4px;
}

.subtitle {
    margin: 8px 0 0;
    font-size: 0.85rem;
    color: #8b9bb4;
    font-weight: 500;
    letter-spacing: 0.5px;
}

.mobile-top-bar {
    display: none;
}

/* ==========================================================================
   LAYOUT PRINCIPAL
   ========================================================================== */
.emulador-layout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 28px;
    padding: 10px 24px 20px;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
    flex: 1;
}

/* Paneles Laterales de PC */
.panel-lateral {
    flex: 0 0 280px;
    max-width: 280px;
}

.card-arcade {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    padding: 16px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-subtle);
}

.card-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}
.card-dot.red { background: var(--neon-red); box-shadow: 0 0 6px var(--neon-red); }
.card-dot.yellow { background: var(--retro-yellow); box-shadow: 0 0 6px var(--retro-yellow); }
.card-dot.green { background: var(--retro-green); box-shadow: 0 0 6px var(--retro-green); }
.card-dot.blue { background: var(--neon-blue); box-shadow: 0 0 6px var(--neon-blue); }

.card-header h3 {
    margin: 0;
    font-family: var(--font-retro);
    font-size: 0.72rem;
    letter-spacing: 1px;
    color: #e2e8f0;
}

.control-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 0.85rem;
}

.control-label {
    color: #94a3b8;
    font-weight: 500;
}

.key-cluster {
    display: flex;
    gap: 4px;
}

.kbd-key {
    background: #0f131f;
    border: 1px solid #333d59;
    border-bottom: 3px solid #1e2538;
    color: #f8fafc;
    font-family: var(--font-retro);
    font-size: 0.65rem;
    padding: 5px 8px;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.4);
}

.kbd-key.accent-a {
    color: var(--neon-red);
    border-color: rgba(255, 51, 102, 0.4);
}
.kbd-key.accent-b {
    color: var(--retro-yellow);
    border-color: rgba(255, 184, 0, 0.4);
}

.kbd-combo {
    background: linear-gradient(135deg, rgba(255,184,0,0.15), rgba(255,51,102,0.15));
    border: 1px solid var(--neon-red);
    color: #fff;
    font-family: var(--font-retro);
    font-size: 0.6rem;
    padding: 4px 7px;
    border-radius: 6px;
}

/* Indicador Gamepad */
.gamepad-card {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #0d101a;
    border: 1px solid #232a3f;
    border-radius: 8px;
    padding: 10px;
    margin-top: 14px;
}

.gamepad-led {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.gamepad-led.off {
    background: #475569;
}
.gamepad-led.connected {
    background: var(--retro-green);
    box-shadow: 0 0 10px var(--retro-green);
    animation: blink-green 2s infinite;
}

@keyframes blink-green {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.gamepad-text {
    font-size: 0.72rem;
    color: #94a3b8;
    font-family: monospace;
}

/* Panel Derecho: Info & Cafecito */
.tech-info p {
    margin: 6px 0;
    font-size: 0.8rem;
    color: #cbd5e1;
    line-height: 1.4;
}
.tech-info strong {
    color: #94a3b8;
}

.divider-retro {
    height: 1px;
    background: linear-gradient(to right, transparent, var(--border-subtle), transparent);
    margin: 14px 0;
}

.cafecito-widget {
    background: rgba(255, 184, 0, 0.06);
    border: 1px dashed rgba(255, 184, 0, 0.3);
    border-radius: 10px;
    padding: 12px;
    text-align: center;
}

.cafecito-title {
    font-family: var(--font-retro);
    font-size: 0.65rem;
    color: var(--retro-yellow);
    margin: 0 0 4px;
}

.cafecito-sub {
    font-size: 0.75rem;
    color: #94a3b8;
    margin: 0 0 10px;
}

.btn-cafecito-arcade img {
    width: 130px;
    border-radius: 8px;
    transition: transform 0.2s, filter 0.2s;
}

.btn-cafecito-arcade:hover img {
    transform: scale(1.05);
    filter: brightness(1.1);
}

.legal-note {
    font-size: 0.7rem;
    color: #64748b;
    line-height: 1.4;
    margin: 0;
}

/* ==========================================================================
   GABINETE ARCADE & PANTALLA GIGANTE (DESKTOP)
   ========================================================================== */
.contenedor-principal {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    max-width: 980px;
    width: 100%;
}

.arcade-cabinet {
    background: var(--bg-cabinet);
    border: 3px solid #2d354d;
    border-radius: 20px;
    padding: 14px 18px 16px;
    box-shadow: var(--shadow-cabinet);
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

/* Bisel superior del gabinete */
.cabinet-top-bezel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 12px;
    padding: 0 8px;
}

.power-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
}

.power-led {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--neon-red);
    box-shadow: 0 0 10px var(--neon-red), 0 0 4px #fff;
    animation: led-glow 3s infinite alternate;
}

@keyframes led-glow {
    from { opacity: 0.8; }
    to { opacity: 1; }
}

.power-text {
    font-family: var(--font-retro);
    font-size: 0.55rem;
    color: #94a3b8;
    letter-spacing: 1px;
}

.bezel-badge {
    font-family: var(--font-retro);
    font-size: 0.65rem;
    letter-spacing: 2px;
    color: #cbd5e1;
    text-shadow: 1px 1px 0 #000;
}

.stereo-indicator {
    font-family: monospace;
    font-size: 0.65rem;
    color: #64748b;
}

/* Contenedor del Juego (Escalable & Proporcional) */
.game-container {
    position: relative;
    width: 100%;
    max-width: 920px;
    aspect-ratio: 4 / 3;
    max-height: calc(100vh - 240px);
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 
        inset 0 0 40px rgba(0, 0, 0, 0.9),
        0 6px 20px rgba(0, 0, 0, 0.8);
    border: 4px solid #141724;
}

canvas#nes-canvas {
    width: 100%;
    height: 100%;
    display: block;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

/* Scanlines CRT */
.scanlines-overlay {
    display: none;
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(
        rgba(18, 16, 16, 0) 50%, 
        rgba(0, 0, 0, 0.28) 50%
    );
    background-size: 100% 4px;
    z-index: 2;
    opacity: 0.75;
}

.scanlines-overlay.active {
    display: block;
}

/* Reflejo de cristal curvado CRT */
.crt-glow {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(circle at 50% 40%, rgba(255, 255, 255, 0.04) 0%, transparent 80%);
    box-shadow: inset 0 0 50px rgba(0, 0, 0, 0.6);
    z-index: 3;
}

/* ==========================================================================
   OVERLAY DRAG & DROP EN PANTALLA CRT
   ========================================================================== */
.game-container.drag-active {
    border-color: var(--neon-blue) !important;
    box-shadow: 
        0 0 35px var(--neon-blue-glow),
        inset 0 0 45px rgba(0, 210, 255, 0.45),
        0 8px 30px rgba(0, 0, 0, 0.9) !important;
    transition: all 0.25s ease;
}

.crt-drop-overlay {
    position: absolute;
    inset: 0;
    background: rgba(9, 11, 16, 0.88);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.crt-drop-overlay.visible {
    opacity: 1;
}

.crt-drop-box {
    border: 2px dashed var(--neon-blue);
    border-radius: 12px;
    padding: 24px 32px;
    text-align: center;
    background: rgba(0, 210, 255, 0.08);
    box-shadow: 0 0 25px rgba(0, 210, 255, 0.35), inset 0 0 20px rgba(0, 210, 255, 0.15);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    animation: pulse-drop-box 1.5s infinite ease-in-out;
}

@keyframes pulse-drop-box {
    0%, 100% {
        transform: scale(1);
        border-color: var(--neon-blue);
    }
    50% {
        transform: scale(1.03);
        border-color: #ffffff;
    }
}

.crt-drop-icon {
    font-size: 2.5rem;
    filter: drop-shadow(0 0 10px var(--neon-blue));
    animation: bounce-icon 1s infinite alternate ease-in-out;
}

@keyframes bounce-icon {
    from { transform: translateY(0); }
    to { transform: translateY(-6px); }
}

.crt-drop-text {
    font-family: var(--font-retro);
    font-size: 0.85rem;
    color: #ffffff;
    text-shadow: 0 0 10px var(--neon-blue), 2px 2px 0 #000;
    letter-spacing: 1px;
}

.crt-drop-sub {
    font-family: var(--font-retro);
    font-size: 0.6rem;
    color: var(--retro-yellow);
    letter-spacing: 2px;
    text-transform: uppercase;
}

@media (max-width: 640px) {
    .crt-drop-box {
        padding: 16px 20px;
    }
    .crt-drop-icon {
        font-size: 2rem;
    }
    .crt-drop-text {
        font-size: 0.7rem;
    }
    .crt-drop-sub {
        font-size: 0.5rem;
    }
}

/* Barra inferior del gabinete */
.cabinet-bottom-bar {
    width: 100%;
    margin-top: 14px;
}

.controls-area {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    width: 100%;
}

/* Botones estilo Arcade */
.btn-arcade {
    font-family: var(--font-retro);
    font-size: 0.62rem;
    padding: 11px 18px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    letter-spacing: 0.5px;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: #fff;
    text-shadow: 1px 1px 0 rgba(0,0,0,0.5);
}

.btn-arcade:active {
    transform: translateY(2px);
}

.btn-primary {
    background: linear-gradient(180deg, #ff4d6d 0%, #d91b48 100%);
    box-shadow: 0 4px 0 #9e1032, 0 6px 12px rgba(255, 51, 102, 0.3);
}
.btn-primary:active {
    box-shadow: 0 2px 0 #9e1032;
}

.btn-secondary {
    background: linear-gradient(180deg, #00b4d8 0%, #0077b6 100%);
    box-shadow: 0 4px 0 #023e8a, 0 6px 12px rgba(0, 180, 216, 0.3);
}
.btn-secondary:active {
    box-shadow: 0 2px 0 #023e8a;
}

.btn-tertiary {
    background: linear-gradient(180deg, #475569 0%, #334155 100%);
    box-shadow: 0 4px 0 #1e293b;
}

.btn-toggle {
    background: #181d2e;
    border: 1px solid #333d59;
    box-shadow: 0 4px 0 #111422;
    color: #94a3b8;
}
.btn-toggle.active {
    background: #1b263b;
    border-color: var(--neon-blue);
    color: #00e5ff;
    box-shadow: 0 4px 0 #0d1b2a, 0 0 10px rgba(0, 229, 255, 0.2);
}

/* Footer PC */
.footer-finito {
    text-align: center;
    padding: 12px 20px;
    font-size: 0.8rem;
    color: #64748b;
    margin-top: auto;
}

.footer-finito a {
    color: var(--neon-red);
    text-decoration: none;
    font-weight: 600;
}
.footer-finito a:hover {
    text-decoration: underline;
}

/* Ocultar elementos móviles en desktop */
#mobile-controls {
    display: none;
}

/* ==========================================================================
   MODO PANTALLA COMPLETA (FULLSCREEN)
   ========================================================================== */
body.fullscreen-active .panel-lateral,
body.fullscreen-active .main-header,
body.fullscreen-active .footer-finito,
body.fullscreen-active .cabinet-top-bezel,
body.fullscreen-active .cabinet-bottom-bar {
    display: none !important;
}

body.fullscreen-active .emulador-layout {
    padding: 0;
    margin: 0;
    max-width: 100vw;
    width: 100vw;
    height: 100vh;
}

body.fullscreen-active .contenedor-principal,
body.fullscreen-active .arcade-cabinet {
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    border-radius: 0;
    border: none;
    padding: 0;
    background: #000;
    justify-content: center;
}

body.fullscreen-active .game-container {
    max-width: 100vw;
    max-height: 100vh;
    height: 100vh;
    width: calc(100vh * (4/3));
    border: none;
    border-radius: 0;
}


/* ==========================================================================
   MÓVIL & PANTALLAS TÁCTILES (RESPONSIVE ULTRA REFINADO)
   ========================================================================== */
@media (max-width: 990px) {
    html, body {
        height: 100%;
        height: 100dvh;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
    }

    /* Ocultar elementos de escritorio */
    .panel-lateral,
    .footer-finito,
    .subtitle,
    .by-totii,
    .cabinet-top-bezel,
    .cabinet-bottom-bar {
        display: none !important;
    }

    /* Header Compacto Móvil */
    .main-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        padding: 8px 14px;
        flex: 0 0 auto;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
        background: rgba(9, 11, 16, 0.95);
        backdrop-filter: blur(8px);
    }

    .header-brand {
        gap: 8px;
    }

    .retro-icon {
        font-size: 1.4rem;
    }

    .main-header h1 {
        font-size: 0.95rem;
    }

    /* Barra de botones de acción rápida móvil */
    .mobile-top-bar {
        display: flex;
        align-items: center;
        gap: 6px;
    }

    .m-btn-cafecito {
        background: linear-gradient(180deg, #ffd166 0%, #ffb800 100%);
        color: #121622;
        font-family: var(--font-retro);
        font-size: 0.55rem;
        font-weight: bold;
        padding: 0 9px;
        height: 36px;
        border-radius: 8px;
        display: inline-flex;
        align-items: center;
        gap: 4px;
        text-decoration: none;
        box-shadow: 0 3px 0 #b38000, 0 0 10px rgba(255, 184, 0, 0.4);
        border: none;
        flex-shrink: 0;
        transition: transform 0.15s;
    }
    .m-btn-cafecito:active {
        transform: translateY(2px);
        box-shadow: 0 1px 0 #b38000;
    }

    .top-icon-btn {
        background: #181d2e;
        border: 1px solid #2d354d;
        color: #f1f3f9;
        font-size: 1rem;
        width: 36px;
        height: 36px;
        border-radius: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: background 0.15s;
    }
    .top-icon-btn:active {
        background: #252e47;
        transform: scale(0.95);
    }

    /* Layout Central para Móvil */
    .emulador-layout {
        flex: 1 1 auto;
        padding: 4px 8px;
        margin: 0;
        width: 100%;
        max-width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        overflow: hidden;
    }

    .contenedor-principal {
        width: 100%;
        max-width: 100%;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .arcade-cabinet {
        background: transparent;
        border: none;
        box-shadow: none;
        padding: 0;
        width: 100%;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Pantalla del juego en móvil: ocupa todo el ancho y alto disponible sin desbordar */
    .game-container {
        width: 100%;
        max-width: min(96vw, calc((100dvh - 280px) * (4 / 3)));
        aspect-ratio: 4 / 3;
        max-height: calc(100dvh - 280px);
        border: 2px solid var(--neon-red);
        border-radius: 8px;
        box-shadow: 0 4px 18px rgba(0, 0, 0, 0.8), 0 0 12px rgba(255, 51, 102, 0.25);
    }

    /* Ocultar filtros pesados CRT por defecto en celulares para garantizar 60 FPS limpios */
    .scanlines-overlay:not(.mobile-forced),
    .crt-glow {
        display: none !important;
    }

    /* ==========================================================================
       PAD DE CONTROL MÓVIL (ZONA INFERIOR ERGONÓMICA)
       ========================================================================== */
    #mobile-controls {
        display: flex;
        flex: 0 0 auto;
        width: 100%;
        height: 220px;
        padding: 6px 14px;
        padding-bottom: max(10px, env(safe-area-inset-bottom));
        justify-content: space-between;
        align-items: flex-end;
        position: relative;
        z-index: 100;
        background: linear-gradient(180deg, transparent 0%, rgba(9, 11, 16, 0.85) 30%, #090b10 100%);
        touch-action: none;
    }

    /* --- CRUCETA (D-PAD UNIFICADO) --- */
    .dpad-zone {
        position: relative;
        width: 140px;
        height: 140px;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-bottom: 8px;
    }

    .dpad-cross {
        position: relative;
        width: 132px;
        height: 132px;
        touch-action: none;
        user-select: none;
        -webkit-user-select: none;
    }

    /* Base circular guía para movimiento continuo y diagonales de 8 direcciones */
    .dpad-cross::before {
        content: '';
        position: absolute;
        inset: -6px;
        border-radius: 50%;
        background: radial-gradient(circle, rgba(26, 32, 48, 0.5) 0%, rgba(18, 22, 34, 0.25) 60%, transparent 72%);
        border: 1px dashed rgba(61, 74, 112, 0.35);
        pointer-events: none;
        z-index: 0;
    }

    .dpad-key {
        position: absolute;
        background: #1a2030;
        border: 2px solid #333d59;
        color: #f1f3f9;
        font-size: 1.1rem;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: background 0.1s, transform 0.1s;
    }

    .dpad-key:active,
    .dpad-key.active {
        background: var(--neon-red);
        border-color: #fff;
        color: #fff;
        box-shadow: 0 0 10px var(--neon-red);
    }

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

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

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

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

    .dpad-center-hub {
        position: absolute;
        top: 44px;
        left: 44px;
        width: 44px;
        height: 44px;
        background: #131724;
        border-radius: 4px;
        pointer-events: none;
    }

    /* --- CENTRO: SELECT & START --- */
    .center-pill-zone {
        display: flex;
        flex-direction: column;
        justify-content: flex-end;
        align-items: center;
        margin-bottom: 12px;
    }

    .pill-group {
        display: flex;
        gap: 10px;
    }

    .pill-retro-btn {
        background: #1b2030;
        border: 2px solid #333d59;
        color: #94a3b8;
        font-family: var(--font-retro);
        font-size: 0.52rem;
        padding: 7px 12px;
        border-radius: 14px;
        letter-spacing: 0.5px;
        cursor: pointer;
        box-shadow: 0 3px 0 #0d101a;
    }

    .pill-retro-btn:active,
    .pill-retro-btn.active {
        transform: translateY(2px);
        box-shadow: 0 1px 0 #0d101a;
        background: #2b334d;
        color: #fff;
    }

    /* --- BOTONERA DERECHA: B, A y COMBO [A+B] --- */
    .action-buttons-zone {
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        justify-content: flex-end;
        margin-bottom: 6px;
    }

    .action-cluster {
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        gap: 8px;
    }

    .action-pair {
        display: flex;
        align-items: center;
        gap: 12px;
    }

    .round-retro-btn {
        width: 58px;
        height: 58px;
        border-radius: 50%;
        border: 2px solid rgba(255, 255, 255, 0.4);
        color: #ffffff;
        font-family: var(--font-retro);
        font-size: 1.15rem;
        font-weight: bold;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: transform 0.1s, box-shadow 0.1s;
    }

    .round-retro-btn:active,
    .round-retro-btn.active {
        transform: scale(0.92) translateY(2px);
    }

    .btn-b {
        background: radial-gradient(circle at 35% 35%, #ffd166 0%, #d48b00 100%);
        box-shadow: 0 4px 0 #8c5b00, 0 6px 14px rgba(255, 184, 0, 0.35);
        margin-top: 14px; /* Inclinación ergonómica tipo Nintendo */
    }
    .btn-b:active,
    .btn-b.active {
        box-shadow: 0 2px 0 #8c5b00;
    }

    .btn-a {
        background: radial-gradient(circle at 35% 35%, #ff4d6d 0%, #c9184a 100%);
        box-shadow: 0 4px 0 #800f2f, 0 6px 14px rgba(255, 51, 102, 0.4);
    }
    .btn-a:active,
    .btn-a.active {
        box-shadow: 0 2px 0 #800f2f;
    }

    /* Botón Combo [A+B] */
    .btn-combo-ab {
        background: linear-gradient(135deg, rgba(255,184,0,0.2) 0%, rgba(255,51,102,0.25) 100%);
        border: 2px solid #ff758c;
        border-radius: 12px;
        padding: 5px 14px;
        display: flex;
        flex-direction: column;
        align-items: center;
        cursor: pointer;
        box-shadow: 0 3px 0 #701127;
        margin-right: 6px;
    }
    .btn-combo-ab:active,
    .btn-combo-ab.active {
        transform: translateY(2px);
        box-shadow: 0 1px 0 #701127;
        background: linear-gradient(135deg, #ffd166 0%, #ff4d6d 100%);
    }

    .combo-label {
        font-family: var(--font-retro);
        font-size: 0.65rem;
        color: #fff;
        font-weight: bold;
    }
    .combo-sub {
        font-size: 0.5rem;
        color: #ffb800;
        font-weight: 700;
    }
}

/* ==========================================================================
   MODO HORIZONTAL / LANDSCAPE (CONSOLA PORTÁTIL NINTENDO SWITCH / GBA)
   ========================================================================== */
@media (orientation: landscape) and (max-height: 520px) {
    html, body {
        height: 100dvh;
        overflow: hidden;
    }

    .main-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        padding: 4px 12px;
        background: rgba(9, 11, 16, 0.85);
        z-index: 150;
    }

    .main-header h1,
    .retro-icon {
        font-size: 0.75rem;
    }

    .top-icon-btn {
        width: 30px;
        height: 30px;
        font-size: 0.85rem;
    }

    .emulador-layout {
        position: absolute;
        inset: 0;
        padding: 0;
        width: 100vw;
        height: 100dvh;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .game-container {
        height: calc(100dvh - 16px);
        max-height: 100dvh;
        width: calc((100dvh - 16px) * (4 / 3));
        max-width: calc(100vw - 220px);
        aspect-ratio: 4 / 3;
        border: 2px solid var(--neon-red);
    }

    #mobile-controls {
        position: absolute;
        inset: 0;
        width: 100vw;
        height: 100dvh;
        background: transparent;
        pointer-events: none;
        padding: 10px 20px;
        display: flex;
        justify-content: space-between;
        align-items: flex-end;
    }

    .dpad-zone, 
    .action-buttons-zone, 
    .center-pill-zone {
        pointer-events: auto;
    }

    .dpad-zone {
        width: 120px;
        height: 120px;
        margin-bottom: 12px;
        margin-left: 6px;
    }
    .dpad-cross {
        width: 114px;
        height: 114px;
    }
    .dpad-up, .dpad-down {
        left: 38px;
        width: 38px;
        height: 42px;
    }
    .dpad-left, .dpad-right {
        top: 38px;
        width: 42px;
        height: 38px;
    }
    .dpad-center-hub {
        top: 38px;
        left: 38px;
        width: 38px;
        height: 38px;
    }

    .action-buttons-zone {
        margin-bottom: 12px;
        margin-right: 6px;
    }
    .round-retro-btn {
        width: 50px;
        height: 50px;
        font-size: 1rem;
    }

    .center-pill-zone {
        position: absolute;
        bottom: 8px;
        left: 50%;
        transform: translateX(-50%);
        margin-bottom: 0;
    }
}

/* Corrección de cruceta: los botones internos no deben interceptar el touch pointer */
.dpad-cross {
    touch-action: none;
    pointer-events: auto;
}

.dpad-cross .dpad-key,
.dpad-cross .dpad-center-hub {
    pointer-events: none; /* Crucial: el cálculo de ángulo se delega íntegro al contenedor padre */
}

/* Indicador visual al arrastrar ROM a la pantalla */
.arcade-cabinet.drag-active {
    outline: 3px dashed var(--neon-blue);
    outline-offset: -6px;
    filter: drop-shadow(0 0 15px var(--neon-blue-glow));
}